-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
Missing report on potential null property when using a dynamic child property #1499
Labels
Comments
dbu
changed the title
Missing report on potential null field when using a dynamic child field
Missing report on potential null property when using a dynamic child property
Oct 11, 2018
Please attach phpstan.org link as stated in the instructions.
On Thu, 11 Oct 2018 at 12:16, David Buchmann ***@***.***> wrote:
Summary of a problem or a feature request
We do get a warning for the line with explicit field name in the map, but
no warning when a property of a nullable property is accessed with a
dynamic name.
Code snippet that reproduces the problem
class Product{ /** * @var MyMap|null */ public $map;}class MyMap{ public const FIELDS = ['a', 'b']; public $a; public $b;}$product = new Product();foreach (MyMap::FIELDS as $field) { print($product->map->$field);}print($product->map->a);
Expected output
Warning that $product->map->$field could be null because Product::$map is
nullable.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1499>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuMX9ErJzooPTJblTtWRaSbKY8DwCks5ujxqDgaJpZM4XXOej>
.
--
Ondřej Mirtes
|
sorry, missed that. here you go: https://phpstan.org/r/d9a1196f5eea4480f3a33c48547b71f1 |
This already works thanks to phpstan/phpstan-src#348. |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Summary of a problem or a feature request
We do get a warning for the line with explicit field name in the map, but no warning when a property of a nullable property is accessed with a dynamic name.
Code snippet that reproduces the problem
Expected output
Warning that $product->map->$field could be null because Product::$map is nullable.
The text was updated successfully, but these errors were encountered: