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

4.x phpstan #210

Merged
merged 13 commits into from
Jul 19, 2018
Merged

4.x phpstan #210

merged 13 commits into from
Jul 19, 2018

Conversation

SignpostMarv
Copy link
Contributor

  • resolved Confusing phpstan errors #207
  • switched from phpstan/phpstan-shim to phpstan/phpstan,
  • adjusted the composer script to behave nicely on gitbash/travis etc.
  • bumped up some of the phpstan levels, resolved issues.

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

@GrahamCampbell
Copy link
Contributor

switched from phpstan/phpstan-shim to phpstan/phpstan,

why?

@mhujer
Copy link
Contributor

mhujer commented Jan 28, 2018

I already fixed issues from #207 in #208.

@SignpostMarv
Copy link
Contributor Author

@GrahamCampbell in order to use the config files defined in the phpstan package, hoping to progress towards config.levelmax.neon + phpstan-strict-rules

@mhujer I missed that- shall I rebase onto mhujer:mh-4.x-rebase-fixes ?

@ramsey
Copy link
Owner

ramsey commented Jan 28, 2018

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.

@ramsey
Copy link
Owner

ramsey commented Feb 8, 2018

I just merged #208 into 4.x. Should this be rebased against 4.x before I merge it?

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"
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 :)

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor

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.

@mhujer
Copy link
Contributor

mhujer commented Feb 9, 2018

@ramsey this should definitely be rebased before merging it to 4.x to verify that the build still passes

@SignpostMarv
Copy link
Contributor Author

SignpostMarv commented Feb 13, 2018

rebasing at the moment, dropping the phpunit configs as they seemed to have no effect on the output. i.e.
a0c6e23

SignpostMarv added a commit to SignpostMarv/uuid that referenced this pull request Feb 13, 2018
@SignpostMarv
Copy link
Contributor Author

SignpostMarv commented Feb 13, 2018

PHP Fatal error: Uncaught RuntimeException: You need to provide valid cache directory for Go! AOP framework. in /home/travis/build/ramsey/uuid/vendor/goaop/framework/src/Core/AspectKernel.php:208

lolwhut ?

*/
public function getNode()
{
foreach ($this->nodeProviders as $provider) {
if ($node = $provider->getNode()) {
if ((bool) ($node = $provider->getNode())) {
Copy link
Contributor

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
Copy link
Contributor

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)

Copy link
Contributor Author

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 ?

Copy link
Contributor

@mhujer mhujer Feb 15, 2018

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 ;-) )

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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 ?

@SignpostMarv
Copy link
Contributor Author

have rolled back the strict rules commits so we ca put them on a separate pr later

@mhujer
Copy link
Contributor

mhujer commented Feb 21, 2018

I've created a PR which fixes the build #214

@SignpostMarv
Copy link
Contributor Author

@mhujer rebased, seems to be passing now.

@ramsey
Copy link
Owner

ramsey commented Jul 19, 2018

Thank you for contributing! 🎉

@ramsey ramsey merged commit ae67e4c into ramsey:4.x Jul 19, 2018
@SignpostMarv SignpostMarv deleted the 4.x--phpstan branch July 19, 2018 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants