-
-
Notifications
You must be signed in to change notification settings - Fork 947
Native types todos #8191
Copy link
Copy link
Closed
Labels
Description
Feature request
1.9.x is now pretty broken for projects with treatPhpDocTypesAsCertain: false: https://github.com/phpstan/phpstan/actions/runs/3297631860/jobs/5438715560
This is because there's some work underway, but more needs to be done to fully implement it. From phpstan/phpstan-src#1802 I already merged some commits into 1.9.x: phpstan/phpstan-src@f097ca9...bf34e24
Before the rest of phpstan/phpstan-src#1802 is finished and merged, we have some work to do (in this order with no skipping):
- Get rid of
$nativeExpressionTypesproperty in MutatingScope, in favour of$variableNativeTypes. - Add and correctly populate
$moreSpecificNativeTypesto MutatingScope. The hard question is what to do about TypeSpecifier. We probably need to call it twice infilterByTruthyValue/filterByFalseyValue/filterBySpecifiedTypesfor complete and native types in order to have correct information. - Some preliminary work too in order to retrieve native return type from ExtendedMethodReflection nicely, same for PropertyReflection.
And on top of phpstan/phpstan-src#1802:
- Get rid of phpstan/phpstan-src@
8f7bbf7(#1802) and do it in a smarter way.MutatingScope::getNativeType()should probably be implemented with a simple one-liner:return $this->promoteNativeTypes()->getType($node);and for expressions where the implementation is different do an if-else based onbool $this->nativeTypesPromoted. But most expressions will be the same.
To remind, having Scope::getNativeType() to answer truthfully for all expressions will allow us to do some cool features:
- I'll be able to implement a rule that checks when an inline
@varis always wrong, because the thing on the right side of=has a different type than what it's cast to. - I'll be able to eventually redesign rule levels and do a different slice across the whole rules catalogue to report useful errors earlier.
Reactions are currently unavailable