-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[stable10] Introduce phpstan #35774
[stable10] Introduce phpstan #35774
Conversation
@@ -89,7 +89,7 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = | |||
$sourceScanner = $this->getSourceScanner(); | |||
if ($sourceScanner instanceof NoopScanner) { | |||
list(, $internalPath) = $this->storage->resolvePath($file); | |||
return parent::scan($internalPath, $reuseExisting, $parentId, $cacheData, $lock); | |||
return parent::scan($internalPath, self::SCAN_SHALLOW, $reuseExisting, $lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this code ever get called?
The params were wrong.
See #32377 (comment)
#32377 has touched/fixed this code in master
but never got backported.
e7a0568
to
686aa34
Compare
Codecov Report
@@ Coverage Diff @@
## stable10 #35774 +/- ##
==============================================
+ Coverage 64.84% 65.09% +0.25%
+ Complexity 20243 20238 -5
==============================================
Files 1299 1300 +1
Lines 77220 77237 +17
Branches 1301 1301
==============================================
+ Hits 50070 50278 +208
+ Misses 26765 26574 -191
Partials 385 385
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## stable10 #35774 +/- ##
===============================================
- Coverage 64.99% 45.68% -19.31%
===============================================
Files 1302 116 -1186
Lines 77354 11519 -65835
Branches 1301 1301
===============================================
- Hits 50274 5263 -45011
+ Misses 26695 5871 -20824
Partials 385 385
Continue to review full report at Codecov.
|
645b3d7
to
b42a0e9
Compare
@@ -9,6 +9,7 @@ | |||
/build/composer.phar | |||
/build/dist | |||
/build/phan.phar | |||
/build/phpstan.phar* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this comes from the backport.
Similar to /build/phan.phar
above it. these files should not even appear in the build
directory these days - the tools are in vendor-bin
But we can remove these later. For now, this gets stable10
matching master
@@ -78,7 +78,7 @@ public function getStatus() { | |||
public function getPrivateKey() { | |||
$key = $this->session->get('privateKey'); | |||
if ($key === null) { | |||
throw new Exceptions\PrivateKeyMissingException('please try to log-out and log-in again', 0); | |||
throw new Exceptions\PrivateKeyMissingException('please try to log-out and log-in again'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit weird, but it happens in other places also - the first parameter is supposed to be the "text" version of the user name. Whatever text is passed ends up getting into the text of the exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is encryption
app code - so was not being analyzed by phpstan
in master
because it does not exist in master
@@ -26,6 +26,8 @@ | |||
|
|||
class InvalidStorage extends FailedStorage { | |||
public function __construct($params) { | |||
$params['exception'] = new StorageNotAvailableException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php
(and phpstan
) wants the constructor to have a $params
arg like FailedStorage
But then phpstan
complains that $params
is not used.
So this code uses it ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mystery is that in master
the constructor has no parameters, and phpstan
does not complain in master
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See for answer: #32051 (comment)
if (!\is_array($arguments)) { | ||
$arguments = []; | ||
} | ||
$arguments['datadir'] = \OC::$server->getTempManager()->getTemporaryFolder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpstan
complained about unused $arguments
- so this code uses $arguments
@@ -61,7 +61,7 @@ public function __construct(ControllerMethodReflector $reflector, | |||
public function beforeController($controller, $methodName) { | |||
if (!$this->reflector->hasAnnotation('NoSubadminRequired')) { | |||
if (!$this->isSubAdmin) { | |||
throw new NotAdminException('Logged in user must be a subadmin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NotAdminException
does not accepts any parameter. And it inherits from a parent that has no parameter.
I made a new NotSubadminException
which can have this text.
Is that the reasonable thing to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code went to the user_management app and disappeared from core master
in core PR #30960
So that is why phpstan
did not notice it in core master
The code in the user_management
app has this same "feature"
b42a0e9
to
8559248
Compare
Great! Passes CI |
yes, I fought with that for a bit - there s a list of small commits in this PR that are extra to what happened in |
phpstan.neon
Outdated
@@ -22,12 +24,15 @@ parameters: | |||
- %currentWorkingDirectory%/apps/*/appinfo/routes.php | |||
- %currentWorkingDirectory%/apps/*/composer/* | |||
- %currentWorkingDirectory%/apps/*/3rdparty/* | |||
- %currentWorkingDirectory%/apps/files/appinfo/update.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because apps/files/appinfo/update.php
was deleted from master
by #33209 so it never had to be considered in the master
PHPstan.
The code is not a class, it is just some old script. It gives:
------ --------------------------------------------------------------------------------------------------------------------------------
Line apps/files/appinfo/update.php
------ --------------------------------------------------------------------------------------------------------------------------------
52 Function owncloud_reset_encrypted_flag not found while trying to analyse it - autoloading is probably not configured properly.
72 Function owncloud_reset_encrypted_flag not found.
79 Function owncloud_reset_encrypted_flag not found.
------ --------------------------------------------------------------------------------------------------------------------------------
and I couldn't work out how to "autoload" it. Seems not worth more time, so ignore it, and maybe delete it in #35781
@@ -78,7 +78,7 @@ public function getStatus() { | |||
public function getPrivateKey() { | |||
$key = $this->session->get('privateKey'); | |||
if ($key === null) { | |||
throw new Exceptions\PrivateKeyMissingException('please try to log-out and log-in again', 0); | |||
throw new Exceptions\PrivateKeyMissingException('please try to log-out and log-in again'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is encryption
app code - so was not being analyzed by phpstan
in master
because it does not exist in master
/** | ||
* @var string | ||
*/ | ||
private $id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole file does not exist any more in master
so that is why phpstan
did not report about it in master
be69acd
to
28d8ccf
Compare
…ed without any parameters'
…nused parameter '
…eption constructor invoked with 1 parameter, 0 required'
28d8ccf
to
c1b5129
Compare
c1b5129
to
1b368f7
Compare
@DeepDiver1975 @micbar @patrickjahns I don't see anything more that I can tidy up here. Please review. |
Description
stable10
thatphpstan
reports.Also fixes #35773
Motivation and Context
When trying some things for "drop PHP 7.0" and for PHPunit7 I noticed some problems and ended up in some of the same code that was corrected/adjusted by
master
PR #31810Issue
How Has This Been Tested?
Local run of:
Types of changes
Checklist: