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
Iterating over type with static #4267
Comments
more details on how to fix: #4220 (reply in thread) |
@ondrejmirtes I was able to fix it with this patch: https://github.com/mvorisek/atk4-hintable-mirror/blob/1.1.5/patch-phpstan-static-type-issue-4267.php here is the patch in an action: https://github.com/atk4/data/pull/821/files fix for |
I filed this issue among hundreds other bug reports and feature requests, please adjust your expectations accordingly. It can take some time before I think of this as a priority. I consider this https://phpstan.org/r/9829582c-f3a5-48e4-ae43-d43d709e8282 a very good workaround. |
The phpstan patch I released fixes this issue, but of course it is a fragile/short term solution. |
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-24: Access to an undefined property Model::$x.
+No errors |
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
- 3: Class Model implements generic interface IteratorAggregate but does not specify its types: TKey, TValue
-21: Access to an undefined property Model::$x.
+ 3: Class Model implements generic interface IteratorAggregate but does not specify its types: TKey, TValue Full report
|
This frikking thing took me 3 days to figure out... phpstan/phpstan-src#474 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Originally reported: #4220
Both versions with generics and without generics should work.
It might just be a matter of modifying ObjectType::getIterableValueType(), to resolve the StaticType (similar to this https://github.com/phpstan/phpstan-src/blob/19bf582aa3c0e0809446a17399d17d17ab40297c/src/Analyser/MutatingScope.php#L4515-L4526).
Code snippet that reproduces the problem
Expected output
Correctly resolved
$h
to HelloWorld.The text was updated successfully, but these errors were encountered: