-
-
Notifications
You must be signed in to change notification settings - Fork 500
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
4.x phpstan #210
4.x phpstan #210
Conversation
why? |
@GrahamCampbell in order to use the config files defined in the phpstan package, hoping to progress towards @mhujer I missed that- shall I rebase onto |
I’m still not sure what the point of all this work is. It seems like a lot of rigid overhead with little value. I’m happy to include phpstan if others are able to address problems that arise from it, but if I have to keep scratching my head at its error messages, I will likely remove it. |
I just merged #208 into |
composer.json
Outdated
"phpstan analyse -c phpstan.neon src --level 2 --no-progress", | ||
"phpstan analyse -c phpstan-tests.neon tests --level 2 --no-progress" | ||
"php vendor/phpstan/phpstan/bin/phpstan analyse -c phpstan.neon src --no-progress", | ||
"php vendor/phpstan/phpstan/bin/phpstan analyse -c phpstan-tests.neon tests --no-progress" |
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 the change from phpstan
to the whole path? It should work the old way.
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
uses whichever version of phpstan is found under $PATH
vendor/bin/phpstan
would work, except for some windows environments, i.e. git bash
vendor/phpstan/phpstan/bin/phpstan
refers specifically to the version required by the composer.json
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.
It should always use the one installed through the Composer, see the docs.
Note: Before executing scripts, Composer's bin-dir is temporarily pushed on top of the PATH environment variable so that binaries of dependencies are easily accessible. In this example no matter if the phpunit binary is actually in vendor/bin/phpunit or bin/phpunit it will be found and executed.
In what situation it did not work as expected?
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.
It should always use the one installed through the Composer, see the docs.
might be an artefact of past experience/earlier development environments. checking now.
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.
yup, I stand corrected - always nice to learn new things :)
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.
Great! I was afraid it is actually broken (I use similar configuration elsewhere)
phpstan.neon
Outdated
@@ -1,3 +1,5 @@ | |||
includes: | |||
- vendor/phpstan/phpstan/conf/config.level5.neon |
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 is this better than just passing the level from CLI parameters?
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.
it might've changed recently, but there's no cli parameter for the max level, which currently aliases to -l7
, but may change in future.
there's also the phpstan/phpstan-strict-rules
ruleset, as well as any custom configurations that may be required in future.
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.
Yes, it's possible to use max in CLI.
You can also use
--level max
as an alias for the highest level.
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.
well colour me corrected ('ve been using the shorthand cli args) :P
pretty sure that importing rules still stands?
i.e. roll back the config file change until such a time as we've got ramsey/uuid passing --level max & we can pull in strict-rules ?
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.
Yep, other rules/extensions should be imported in the config.
@ramsey this should definitely be rebased before merging it to 4.x to verify that the build still passes |
rebasing at the moment, dropping the phpunit configs as they seemed to have no effect on the output. i.e. |
0d2f2f1
to
ce02517
Compare
…ast/math, as mentioned in ramsey#210
lolwhut ? |
*/ | ||
public function getNode() | ||
{ | ||
foreach ($this->nodeProviders as $provider) { | ||
if ($node = $provider->getNode()) { | ||
if ((bool) ($node = $provider->getNode())) { |
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.
What about something like this:
$node = $provider->getNode();
if ($node !== null) {
return $node;
}
When PHPStan warns you, that there is implicit boolean conversion in condition, it does not mean that it should be replaced with explicit 😄
phpstan.neon
Outdated
@@ -1,7 +1,10 @@ | |||
includes: | |||
- ./vendor/phpstan/phpstan-strict-rules/rules.neon |
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 would put this (and the necessary changes) in a separate PR.
I think it makes sense to fix the stuff PHPStan detects with the standard checks first. And then consider enabling this. (When doing both at the same time, you can't tell if the strange Travis error is related to this or not)
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 changes are relatively minimal for it to pass the strict rules ?
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.
They probably are, so maybe it would be a wasted afford in this case.
Anyway, I just tried to build the 4.x
branch itself and it fails as well https://travis-ci.org/mhujer/uuid/jobs/341774850 - so it is probably caused by a new version of https://github.com/goaop/framework/releases
Probably it would be enough to configure cacheDir
https://github.com/goaop/framework#3-configure-the-aspect-kernel-in-the-front-controller in tests/bootstrap.php
(I would love to see this in a separate PR though ;-) )
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.
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've been giving some thought to separate pull requests on turning the error suppression back off- tinkering with an autoload-dev shim that matches the method signatures of the missing functions & constants, but throws BadFunctionCallException
if inadvertently called ?
ce02517
to
2e45b91
Compare
have rolled back the strict rules commits so we ca put them on a separate pr later |
I've created a PR which fixes the build #214 |
… on Ramsey\Uuid\Converter\TimeConverterInterface::calculateTime()
…y phpstan level 3
…ast/math, as mentioned in ramsey#210
…y RandomLibAdapter::$generator not being type hinted as nullable
2e45b91
to
4643624
Compare
@mhujer rebased, seems to be passing now. |
Thank you for contributing! 🎉 |
a phpdoc block in moontoast/math is holding up level 6: https://github.com/ramsey/moontoast-math/blob/c2792a25df5cad4ff3d760dd37078fc5b6fccc79/src/Moontoast/Math/BigNumber.php#L633 , i.e. BigNumber is being passed in when the docs specify string|int