-
-
Notifications
You must be signed in to change notification settings - Fork 687
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
Get ready for PHPStan 2.0 #8815
Comments
Sounds good 👍 We'll give this a priority by the end of the year and do upgrade of both PHPStan 2 and php-parser 5 at once. |
We're now in the release candidate period phpstan/phpstan#11816 |
rector phpstan's extensions seems need to have compatible to phpstan 2 first:
|
@TomasVotruba Today is 11.11. Do you plan to make Rector PHPStan 2 compatible this week? |
First step: symplify/phpstan-extensions#12 |
@szepeviktor Depends how many only-in-Rector BC breaks we'll have to deal with. We use lot of internal code, so it might be a challange. @samsonasik Could you look into it? |
@TomasVotruba sure, phpstan 2 require php-parser 5 so it will need revisit my old PR: to be reincorporated ;) |
I think best way to start is to enable bleeding edge and maybe install |
Exactly, as the upgrading guide says! |
sure, see rectorphp/rector-src#6415 |
I created this PR for |
Another PR for |
I am trying to install phpstan 2 and php-parser 5 the php-parser is patched, and currently got error on phpstan service:
|
The upgrade process has been completed 🎉 🎉 🎉 |
Are there any plans for a new release? |
@FabianKoestring We're testing the dev branch now in couple big projects. There are still breaks in docblocks we have to verify to avoid mess. Date 12. 12. seems like best :) If you can try out latest Rector dev and report feedback from your project, it would speedup the process 🙂 {
"require-dev": {
"phpstan/phpstan": "^2.0",
"rector/rector": "dev-main"
}
} |
I've switched to the dev branch (so that I could install phpstan 2), and haven't had any issues. Granted, my use cases are fairly straightforward and common (just adding return types is a huge help!) |
There is an issue going on with conditional return types. Had a few files that failed. |
A really good project to also test is TYPO3 Rector. I've tried it out with: "require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"league/flysystem": "^2.0 || ^3.0",
"league/flysystem-memory": "^2.0 || ^3.0",
"nette/utils": "^3.2.10 || ^4.0.4",
"nikic/php-parser": "^4.18.0",
- "phpstan/phpstan": "^1.10.56",
- "rector/rector": "^1.1.0",
+ "phpstan/phpstan": "^2.0",
+ "rector/rector": "dev-main",
"symfony/console": "^5.4 || ^6.4 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.4 || ^7.0",
"symfony/finder": "^5.4 || ^6.4 || ^7.0",
"symfony/polyfill-php80": "^1.28.0",
"symfony/polyfill-php81": "^1.28.0",
"symfony/string": "^5.4 || ^6.4 || ^7.0",
"webmozart/assert": "^1.11.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpstan/extension-installer": "^1.3.1",
- "phpstan/phpstan-deprecation-rules": "^1.1.4",
- "phpstan/phpstan-phpunit": "^1.3.16",
"phpunit/phpunit": "^9.6.17 || ^10.0",
"symfony/config": "^5.0 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4.36 || ^6.4.2 || ^7.0.2",
"symfony/http-kernel": "^5.4.37 || ^6.4.2 || ^7.0.2",
"symplify/easy-coding-standard": "^12.1.14"
}, and then run: composer update
vendor/bin/rector process and I'm getting some phpstan error:
|
@simonschaufi I created PR on typo-3 rector for that :) |
I tried the new version with our project and could not find any problems. Rector was able to find several new issues, but all these finds were correct, they were genuine problems that had not been detected before Our project is mid sized, about 1K PHP files with about 200K lines of code. We apply a lot of Rector rules, around 300 |
Found another issue, but don't understand why it happens: $ vendor/bin/phpstan analyze --debug src-dev/Rector/
/Volumes/CS/www/cosmos/src-dev/Rector/StaticMoneyConstructorRector.php
PHP Fatal error: Dev\Rector\StaticMoneyConstructorRector::getRuleDefinition() has #[\Override] attribute, but no matching parent method exists in /Volumes/CS/www/cosmos/src-dev/Rector/StaticMoneyConstructorRector.php on line 26 Part of the rector: <?php
declare(strict_types=1);
namespace Dev\Rector;
use Money\Currency;
use Money\Money;
use Override;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PhpParser\NodeTraverser;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
final class StaticMoneyConstructorRector extends AbstractRector
{
#[Override]
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition(
'Replace `new Money(10, new Currency("EUR"))` with `Money::EUR(10)`.',
[
new CodeSample(
<<<'CODE_SAMPLE'
new Money(10, new Currency("EUR"));
CODE_SAMPLE,
<<<'CODE_SAMPLE'
Money::EUR(10);
CODE_SAMPLE,
)],
);
}
// ...
} I ran this: $ composer update -W "phpstan/*" rector/rector phpdocumentor/type-resolver phpstan/phpdoc-parser The reason I don't understand it, is that I'm overriding this, as it's part of a higher interface, no? When I remove the
Which is what I expect, because we enforce |
@ruudk It because of this PR:
You can remove |
@ruudk I created PR for that for win win solution: |
@ruudk That's expected. See the upgrade guide, the |
@TomasVotruba does this mean that when we upgrade to Rector 2.0 we need to remove our |
As mentioned in the PR, this is not a solution as it doesn't work: $ vendor/bin/rector process /Volumes/CS/www/cosmos/src-dev/Rector/StaticMoneyConstructorRector.php
PHP Fatal error: Class Dev\Rector\StaticMoneyConstructorRector contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface::getRuleDefinition) in /Volumes/CS/www/cosmos/src-dev/Rector/StaticMoneyConstructorRector.php on line 23
Fatal error: Class Dev\Rector\StaticMoneyConstructorRector contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface::getRuleDefinition) in /Volumes/CS/www/cosmos/src-dev/Rector/StaticMoneyConstructorRector.php on line 23 |
@carlos-granados if on autoload, it conflict with existing package symplify/rule-doc-generator, unfortunatelly, it can't, as autoload conflict, the solution is remove |
I would prefer a solution that would allow us to keep the |
@carlos-granados add |
new PR to avoid conflict with real dependency of |
Just tried rector/dev-main on our project. Works like a charm. Migrated to v2 without any problems! Good work @samsonasik |
For 99 % use cases, they should be removed. The code snippets should be part of tests, if you have any. If you use them in some own tooling to generate documentation, you can implement |
After @samsonasik's latest fix, both Rector and PHPStan work 🎉 |
Feature Request
Hi, I just started working on PHPStan 2.0 which will come with PHP-Parser 5. These are early days of the development, but you can already require
phpstan/phpstan:^2.0
(with minimum-stability dev) and start working on making Rector compatible.There will be more backward compatibility breaks coming in the next few months as I work towards to release, but you can already start getting rector-src ready for Rector 2.0 which will require PHPStan 2.0.
Please keep this issue open so we can discuss the next major PHPStan version. I'd also appreciate any feedback from your side. Thanks. 🤞
The text was updated successfully, but these errors were encountered: