-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
refactor: fix PHPStan errors #9125
base: develop
Are you sure you want to change the base?
Conversation
please create multiple PRs for per-directory basis to make easier to review, also, better fix per error identifier instead of try to fix everything, then you can rebase when one of PRs merged. |
Sorry, we cannot review too big PRs like this (changes: +413 −778). Your one commit is too big and having a lot of different changes,
Read carefully: https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#committing And could you please make multiple very small PRs, and change (fix) one thing in one PR? |
* | ||
* @var list<string> | ||
*/ | ||
public $helpers = []; |
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.
Why did you add the property?
if (! method_exists(InstalledVersions::class, 'getAllRawData')) { | ||
preg_match( | ||
'/\s*"plugin-api-version": "(?\'version\'\d+\.\d+\.\d+)"/m', | ||
file_get_contents(__DIR__ . '/../../composer.lock'), | ||
$matches | ||
); | ||
|
||
if (version_compare($matches['version'], '2.0.14', '<')) { |
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.
Why did you change the code?
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 fix phpstan error:
Call to function method_exists() with 'Composer\InstalledVersions' and 'getAllRawData' will always evaluate to true.
But I think, that better way will be to remove this check and check composer version during composer install
and composer update
...
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.
Okay, I got why. But your code seems to take time more.
The PHPStan error is inevitable. Because we use the latest composer
command.
So I think the error should be suppressed by @phpstan-ignore-next-line
or @phpstan-ignore-line
.
$namespace = 0; | ||
$namespace = ''; |
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.
I don't know why the original code is $namespace = 0;
.
If $namespace
is set to 0
, is the case is just a bug?
Please make another PR to fix this issue.
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.
After changing 151 line in this file it's failing:
- CodeIgniter\Autoloader\FileLocatorCachedTest::testGetClassNameFromClassFile
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'CodeIgniter\Autoloader\FileLocatorTest'
+'0\CodeIgniter\Autoloader\FileLocatorTest'
Ok. I will prepare separate PRs with smaller, internally related scopes. |
👋 Hi, @pawelkg! |
Description
Fix errors from phpstan-baseline.php
Checklist: