Validator not catching a variable via PHPDoc comment [message #1803016] |
Wed, 20 February 2019 22:47 |
Perttu Myry Messages: 1 Registered: February 2019 |
Junior Member |
|
|
We have a lot undefined variable warnings in our project. We use Phalcon and its MVC model and it's quite common in our case that a controller gives an array to a view. Then in the view all the variables given by controller are documented as PHPDoc comments.
For sake of clarity, I simplified this test to a bare minimum setup.
<?php
/** @var array $arr */
echo $arr['test'];
The third line keeps on warning about an unused variable.
What would be a suggested way around this issue? Should the PHPDoc comment somehow also contain information about the array keys? Or is this just a bug in the PDT validator implementation?
What is interesting is that after changing that minimum test case into this the validator no longer warns about an undefined variable.
<?php
/** @var array $arr */
$arr;
echo $arr['test'];
|
|
|
Powered by
FUDForum. Page generated in 0.02789 seconds