-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Upgrade to PHPStan 0.12 #378
Upgrade to PHPStan 0.12 #378
Conversation
This is a work in progress or is already stable? |
Like I wrote, there are still some errors to solve. Need some ideas for how to solve them. |
Thanks! |
Another error: analyzing |
Do you would like to continue this work of the upgrade? |
Some parts, yes I'd like to fix. But for other parts solution is not easy. So I need help, or we need to discuss it. |
I am using the bare phpstan command in my Github Actions instead of the laravel-specific command (not sure why that is the case anymore). Didn't seem to make a difference, so dropping it got my personal vote (if it helps at all). |
Hummm, how about some default options? We need to make sure they are somehow ported. |
I fixed some more errors. There are still some small errors left, but the biggest one (one about the |
PHPStan 0.12 is gonna be released this week. (probably tomorrow) Currently, we only have the I'm writing the error here also so maybe other people can provide a solution too.
|
In order to use 0.12, larastan also required an update but the PR to support 0.12 of phpstan is currently on hold due to an error emitted from the Console command. As I don't use that, this uses my own fork of that PR, removing the Console command entirely to fix the issues. When larastan/larastan#378 is merged, the `repositories` block will need to be removed from composer.json so that we can go back to using the main Larastan releases. Version requirement should also be reset.
Have I resolved it right? |
Since there was some silence about this issue, I went ahead and removed the Laravel specific command we provide. In my opinion, this is a better solution. People will just use PHPStan like they normally would. And it's one less thing to maintain. In the past I see this command cause some issues. Also, I introduced a new And of course in the other branch ( |
+1 |
Please use spaces in phpstan-baseline.neon |
Thanks, that was a PITA especially for people who've already worked with phpstan before 👍 |
Thanks for your work on this, can you double check why tests are passing? I would like to re-discuss the Sorry for arriving late to the discussion. |
Made a tweet about this to collect some feedback: https://twitter.com/enunomaduro/status/1203956328714117121. |
Hi, MutatingScope is no longer marked as
PHPStan no longer allows using its dependencies directly in consumer code. The class should be rewritten - you can hardcode current PHPStan options and arguments, seems like the easiest approach. |
Anyway, please include me in this kind of discussion next time so you don't have to speculate how to solve something, it's valuable feedback for me too... Thanks. |
It definitely shouldn't be dropped for technical reasons. The PHPStan CLI options are stable and do not change that often. They could be hardcoded instead of asking Symfony for them. |
This is essentially a PHPStan extension. So users just install and use the PHPStan like they normally would. Like About |
Travis build is failing because we are running PHPStan on a fresh Laravel instance. And that code has some issues. We can either reduce the level we are running (currently at maximum) or we can try to find another way to test. |
Let me share some of the values why we had this from the first place:
|
I agree, only if they are parsing the output. |
Outputting the notice to stderr should be fine. |
I updated the PR. But I'm not sure why Travis fails. And ideas? |
@canvural I think that I saw that phpstan removed orchestra dependencies |
PHPStan never depended on orchestra. |
It was removed from Larastan in August: 457af86 |
No. It's still there 😄 Edit: It's in the dev dependencies now. And Travis installs dev dependencies, so there shouldn't be a problem. 🤔 |
PHPStan now supports stub files where you can override phpDocs from 3rd party code if they’re wrong or if you for example want to add generics. |
I created a stub like this <?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request);
} and registered in But the error is still there. Also tried with |
The Did you add the stub to |
That Yes, I'm trying to change the |
You could do something like For the record, while I missed the Twitter poll I would also be in favour of removing the Artisan command—or at least making it optional. I use multiple testing & SA tools, none of which operate via artisan. Instead I use |
The artisan command has always been optional. You can run PHPStan directly. If you use phpstan/extension-installer, you don’t even have to include Larastan’s extension.neon manually. |
Sorry @ondrejmirtes, I should have clarified. While it's always been optional in the sense that you don't need to run it, when things do go wrong it can prevent any other artisan commands from being run (as was the case here before it was fixed). If we can't remove it entirely, it'd be nice if there was a way to prevent it being auto-loaded to avoid these issues in future for those that use phpstan directly. Just my two cents though—command or not, this package has still saved a ton of time with all the custom rules, so thanks for everything you folks have done for Larastan! |
@ondrejmirtes makes any sense we require |
@nunomaduro No it doesn't. This package is for "happy path" users only. It should always be installed only by the end user. It's possible that someone wouldn't want it - for example when they want to cherrypick enabled rules from other extensions or that they cannot use it for some other reason. |
I guess this is ready to merge. @nunomaduro I'll update the changelog in a seperate PR. Maybe after |
I would like to review it and prepare some media content about it. What’s new, etc. can you give me one two extra days? @canvural Ps: thousands of developers are grateful for your work on this. |
This PR just upgrades PHPStan to 0.12, nothing new. But there are already some small changes in |
Running a couple tests now on the branch |
PHPStan\Analyser\Scope
is now an interface. And it's only implementationMutatingScope
is marked as@internal
So I removed our scope class. It didn't affect any tests. If we find any error, we can try to fix it in another way.Currently, the biggest issue is in the
OptionsResolver
class. We are getting errors likeParameter #1 $option of method _HumbugBox06db9be5fe9f\Symfony\Component\Console\Input\InputDefinition: :addOption() expects _HumbugBox06db9be5fe9f\Symfony\Component\Console\Input\InputOption, Symfony\Component\Console\Input\InputOption given.
because PHPStan now distrubuted as PHAR file. (IMO we can drop providing a Laravel specific command and just let the users run PHPStan normally)ModelTypeHelper
andRelationCreateExtension
classes still needs some work.Closes #381