Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement phan stan #75

Merged
merged 3 commits into from
Dec 18, 2018
Merged

Implement phan stan #75

merged 3 commits into from
Dec 18, 2018

Conversation

phil-davis
Copy link
Contributor

@phil-davis phil-davis commented Dec 2, 2018

Description

  • implement phan and phpstan in Makefile and drone pipeline steps
  • add phan entries in the drone matrix
  • switch coding-standard from PHP 7.2 to 5.6 (phan effectively does the lint/syntax job for PHP 7.*)
  • code changes to fix issues reported by phan, including moving the locking folder code under lib

This currently includes the pending commits from PR #74 which also awaits review and merge.
This PR has been rebased after merge of PR #74

Checklist:

.drone.yml Outdated Show resolved Hide resolved
use OCA\Testing\ServerFiles;
use OCA\Testing\SysInfo;
use OCP\API;
use OCA\Testing\Opcache;
use OCA\Testing\Logfile;
use OCA\Testing\DavSlowdown;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this ended up just being sorting of the use statements. Makes it easier for humans to scan the list. No difference for the computer.

@@ -44,7 +44,7 @@ public function __construct(IConfig $config, IRequest $request) {

/**
* @param array $parameters
* @return \OC_OCS_Result
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OC_OCS_Result is deprecated. phan reported this in lots of places. Easily fixed.

@@ -76,7 +76,7 @@ public function initialize(Server $server) {
* @param RequestInterface $request request object
* @param ResponseInterface $response response object
* @throws \Sabre\DAV\Exception\Forbidden
* @return boolean
* @return void
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error in PHPdoc reported by phan

@@ -79,7 +79,7 @@ protected function getType($parameters) {

/**
* @param array $parameters
* @return int
* @return string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error in PHPdoc reported by phan

}
$type = $this->getType($parameters);

$lockingProvider = $this->getLockingProvider();

try {
$lockingProvider->acquireLock($path, $type);
$this->config->setAppValue('testing', 'locking_' . $path, $type);
return new \OC_OCS_Result(null, 100);
$this->config->setAppValue('testing', 'locking_' . $path, (string) $type);
Copy link
Contributor Author

@phil-davis phil-davis Dec 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$type is int but setAppValue() expects string. phan reported this. We can explicitly cast to string to make it clear that we know we are doing this.

}
$type = $this->getType($parameters);

$lockingProvider = $this->getLockingProvider();

try {
$lockingProvider->changeLock($path, $type);
$this->config->setAppValue('testing', 'locking_' . $path, $type);
return new \OC_OCS_Result(null, 100);
$this->config->setAppValue('testing', 'locking_' . $path, (string) $type);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$type is int but setAppValue() expects string. phan reported this. We can explicitly cast to string to make it clear that we know we are doing this.

.drone.yml Outdated Show resolved Hide resolved
when:
matrix:
TEST_SUITE: phpunit
PHAN: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickjahns we can only run phan if PHP_VERSION is 7.*
I put a boolean PHAN in here, and only added it to the matrix for 1 phpunit job of PHP 7.0 7.1 and 7.2. Without that, it will try and run for PHP 5.6 also, which will die.

Alternatives would be:

  • put a check in the commands section, and only do make test-php-phan when the PHP version is >=7
  • put a check in Makefile to only really do the phan for PHP>=7, and emit an information message for PHP<7, so that it will "work" with PHP5.6 but be a NOOP
  • or?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickjahns ping ?
There are some other app repos that have good enough code that phan will pass without much (or any) effort.
Before adding drone phan to those, I want to make sure there is a "standard" for doing this in drone.

@phil-davis
Copy link
Contributor Author

@patrickjahns any review comments? merge?

@phil-davis phil-davis merged commit 0e1d8f9 into master Dec 18, 2018
@delete-merged-branch delete-merged-branch bot deleted the implement-phan-stan branch December 18, 2018 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants