-
-
Notifications
You must be signed in to change notification settings - Fork 688
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
Prepare for PHPStan 1.0 #6744
Comments
Thanks Ondra, mainly for the list of changes and commit references 👍 Is there Rector set I can run to upgrade all the BC breaks? 😆 |
There isn't, and I don't know if it's possible to write one because of the circular dependency nature with PHPStan. People would have to stay on an old version of Rector that requires PHPStan 0.12.x in order to run it. |
That can be done, as first you run upgrade code, then I'll see how many changes are needed in Rector + Symplify + custom rules in projects I workh with. If it will be more than 50, I'll put a set together 👍 |
Additional Changes
|
Hi, yeah, if you need Some implementations you can choose from are:
In your case, I'd probably create SimpleParser instance with PHP 8 PhpParser inside (created with Emulative lexer) and wrapped it in CachedParser for faster performance. To see what instances are used in PHPStan, refer to the DI config: https://github.com/phpstan/phpstan-src/blob/99e4ae0dced58fe0be7a7aec3168a5e9d639240a/conf/config.neon#L1517-L1557 and https://github.com/phpstan/phpstan-src/blob/99e4ae0dced58fe0be7a7aec3168a5e9d639240a/conf/config.neon#L1669-L1691 |
@ondrejmirtes Awesome, thanks for details and links! It's very helpful
I'll give it a try 👍
👏 🥇 |
@ondrejmirtes Hi Ondra, I'm almost finished, thank to your specific commit list. Thank you for that. Last issue I have is that in ~10 cases the |
@TomasVotruba Can you show me the code that works with PHPStan and is now broken? Also can it be reproduced on phpstan.org with |
Also please show me example of analysed code that now fails and example of code that still passes, so I can get some ideas what changed. |
It can be seen in any failing test case in this PR: rectorphp/rector-src#1052 E.g. the most isolated error is property fetch in https://github.com/rectorphp/rector-symfony The I'm gonna try to reproduce in demo now. |
Demo seems ok: https://phpstan.org/r/c2dc2a85-d931-4fbf-a639-00dcf6149f17 |
So which parser did you choose? :) Looks like the analysed code is passed through the CleaningParser mentioned above and https://phpstan.org/config-reference#inferprivatepropertytypefromconstructor doesn't work (because it doesn't see the constructor body). |
This will be the problematic class in Rector: https://github.com/rectorphp/rector-src/blob/48cb8a256db8cabbf00d7a125fb838d843d9415e/packages/NodeTypeResolver/NodeTypeResolver/PropertyTypeResolver.php#L43-L47 I'm trying to analyse type of property based on fake property fetch. |
There was no change in parser, we use native php-parser here. The I've found 2 commits in PHPStan that might have affected it: I would try to invert the code manually to verify if thats the place, but due to PHAR I can't change the code. |
That's not true. The code in PHPStan that infers property types from constructor uses some PHPStan's Parser instance. So you need to examine that. |
I mean in our code, I didn't do any change. |
So to make inference work, now the PHPStan parser has to be used? |
You need to do some changes based on this comment #6744 (comment) Because PHPStan internally still uses its own parser. You might have to override |
We can schedule a call for Wednesday morning if you're struggling with this. 👍 |
I'm trying to resolve it last 5 hours without much success :D Call would be very helpful, thank you 👍 At 8/9/10 hrs? |
10:00 would be ideal - we can use Google Meet, or plain old phone call. |
Happy to see such teamwork! 🚀 🤩 @TomasVotruba Is there a timeframe for a next release? |
Rector has support for phpstan ^1.0 but hasn't made a release yet. Please follow rectorphp/rector#6744
there is any ETA for this one? |
Hi, we're currently testing Symplify 10 that is using PHPStan 1.0 and NEON traversing. I think this or start of next week is doable. |
@TomasVotruba another known issue on PHP 7.x The CI github action show the error at |
Looks like this can be closed now 🎉 |
Indeed, thanks for reminder 🤗 |
Yay! Nice work! :) |
Hello everyone 👋
I announced today that PHPStan 1.0 is going to be released on November 1st 2021.
I'm approaching you as one of the most popular projects using PHPStan internally. I'd love if you could prepare your code for PHPStan 1.0 in advance so that it's ready to release on the same day.
Here's a brief guide how to approach the upgrade:
"phpstan/phpstan": "^1.0"
, add"minimum-stability": "dev"
and"prefer-stable": true
if necessary.Thank you!
Here are the BC breaks. The list is huge but most of those have very little impact.
There are new rules around using PHPStan internals in regard to backward compatibility promise: https://phpstan.org/developing-extensions/backward-compatibility-promise
It's possible that not everything you use is covered by it - so I'm here to help you to transition to correct usage, or add some
@api
annotations in PHPStan itself so that more is covered by the promise. Let me know!BC breaks for end-users
max
is now level 9. Feel free to updatemax
to8
if your code isn't ready.numeric-string
(it was previously described asstring&numeric
), and also array shapes.baselineNeon
error formatter, use--generate-baseline
CLI option instead (phpstan/phpstan-src@492cfbc)polluteCatchScopeWithTryAssignments
config parameter (phpstan/phpstan-src@8933c7e)autoload_files
parameter - use Discovering Symbols instead (phpstan/phpstan-src@7a21246)autoload_directories
parameter - use Discovering Symbols instead (phpstan/phpstan-src@f67b48a)bootstrap
parameter - usebootstrapFiles
instead (phpstan/phpstan-src@1baa294)implicitThrows
configuration parameter toexceptions.implicitThrows
(phpstan/phpstan-src@96b7c48)--paths-file
CLI option (phpstan/phpstan-src@5670cf2)dump-deps
command (phpstan/phpstan-src@9c7017c)excludes_analyse
option, useexcludePaths
instead (phpstan/phpstan-src@d25c5e5)The following are interesting only if you create a custom ruleset in your configuration file:
DeadCatchRule
, replaced byCatchWithUnthrownExceptionRule
(phpstan/phpstan-src@4dba60b)VariableCertaintyInIssetRule
, replaced byIssetRule
(phpstan/phpstan-src@2e858de)MissingClosureNativeReturnTypehintRule
, no longer needed thanks to type inference (phpstan/phpstan-src@1c34d8d)BC breaks for extension developers
CompoundTypeHelper
(phpstan/phpstan-src@145c4e3)CommentHelper
(phpstan/phpstan-src@ebad6f6)DependencyDumper
(phpstan/phpstan-src@9c7017c)PHPStan\Reflection\Generic\ResolvedFunctionVariant
, replaced byPHPStan\Reflection\ResolvedFunctionVariant
(phpstan/phpstan-src@1cc6c81)ClassReflection::getNativeMethods()
, usegetNativeReflection()
instead (phpstan/phpstan-src@d2c1446)PhpPropertyReflection::hasPhpDoc()
, replaced byhasPhpDocType()
(phpstan/phpstan-src@bedd5be)NodeDependencies
no longer iterable (phpstan/phpstan-src@f76875a)TestCase
toPHPStanTestCase
(#634), thanks @frankdejonge!StaticType
andThisType
- requireClassReflection
in constructor (phpstan/phpstan-src@7aabc84)PHPStanTestCase
- extensions can no longer be provided by overriding methods fromPHPStanTestCase
. UsegetAdditionalConfigFiles()
instead. (phpstan/phpstan-src@65efd93, phpstan/phpstan-src@239291a)|false
to|null
(phpstan/phpstan-src@629ccf6)BrokerAwareExtension
(phpstan/phpstan-src@db2f7fb)PHPStanTestCase::createBroker()
. UsecreateReflectionProvider()
instead. (phpstan/phpstan-src@1e5cf58)PHPStan\Broker\Broker
. UsePHPStan\Reflection\ReflectionProvider
instead. (phpstan/phpstan-src@c775594)PHPStan\Broker\Broker::getInstance()
. UsePHPStan\Reflection\ReflectionProviderStaticAccessor
instead. (phpstan/phpstan-src@4e7d60d)The text was updated successfully, but these errors were encountered: