[stable10] Introduce phpstan#35774
Conversation
| 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.
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
| /build/composer.phar | ||
| /build/dist | ||
| /build/phan.phar | ||
| /build/phpstan.phar* |
There was a problem hiding this comment.
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
| $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.
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.
This is encryption app code - so was not being analyzed by phpstan in master because it does not exist in master
|
|
||
| class InvalidStorage extends FailedStorage { | ||
| public function __construct($params) { | ||
| $params['exception'] = new StorageNotAvailableException(); |
There was a problem hiding this comment.
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.
The mystery is that in master the constructor has no parameters, and phpstan does not complain in master ???
| if (!\is_array($arguments)) { | ||
| $arguments = []; | ||
| } | ||
| $arguments['datadir'] = \OC::$server->getTempManager()->getTemporaryFolder(); |
There was a problem hiding this comment.
phpstan complained about unused $arguments - so this code uses $arguments
| 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.
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.
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
| - %currentWorkingDirectory%/apps/*/appinfo/routes.php | ||
| - %currentWorkingDirectory%/apps/*/composer/* | ||
| - %currentWorkingDirectory%/apps/*/3rdparty/* | ||
| - %currentWorkingDirectory%/apps/files/appinfo/update.php |
There was a problem hiding this comment.
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
| $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.
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.
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
stable10thatphpstanreports.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
masterPR #31810Issue
How Has This Been Tested?
Local run of:
Types of changes
Checklist: