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
Internal error: Cannot assign an empty string to a string offset in ConstantStringType #6231
Comments
The minimum code that reproduces the issue: https://phpstan.org/r/c40ad6c1-f8d7-4161-86b1-b07e86cb0aa5 |
@T2L the problem with that snippet is that it also crashes in PHP, as expected: https://3v4l.org/jne6e Drupal is adding magic that makes it not crash and requires a more complex sample code |
@mglaman LOL, clearly missed that point, but isn't PHPStan not supposed to actually execute the code, but only parse it ? |
That is true. I do think it's quite brilliant that it's the same either occuring when parsing though |
Fixed: phpstan/phpstan-src@54f67c5 |
@ondrejmirtes wow, thanks! But I think for PHP7.* fix does not work: warning vs error, see https://3v4l.org/jne6e |
Yeah, the test suite showed us that: https://github.com/phpstan/phpstan-src/runs/4883009041?check_suite_focus=true I'm gonna look into it. |
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
Quick note: It's hard to quickly reproduce the same code, I realized after opening that this sample crashes in
https://3v4l.org/
. I'll try to work on an example that runs there BUT crashes for PHPStan. In the mean time, there is the phpstan-drupal test which shows the failure.Drupal has a wonderful class that implements \ArrayAccess and __get and __set which delegate to classes inside of its values. These are our FieldItemList and FieldItem classes.
We experienced PHPStan crashing when trying to analyze Drupal core on the following example of code for this magical madness. I have annotated to help make any sense of this (yes, I know.)
I tried debugging this in mglaman/phpstan-drupal#279. I have no idea how I could try to fix this, even with property reflections.
We have a property reflection to ensure FieldItemList is returned for dynamic entity properties, but that doesn't seem to help.
Here's a screenshot from Xdebug. The property is considered ConstantStringType and breaks when processing the offset value.
Here's the full stack trace when running the test in linked phpstan-drupal PR locally
Code snippet that reproduces the problem
https://phpstan.org/r/95032316-ae1e-4d4c-829c-810ae66fdcbe
Expected output
PHPStan may error but not crash.
Did PHPStan help you today? Did it make you happy in any way?
The text was updated successfully, but these errors were encountered: