Skip to main content



      Home
Home » Language IDEs » PHP Development Tools (PDT) » Validator not catching a variable via PHPDoc comment(Validator warns about undefind variable even when an array is defined via PHPDoc comment)
Validator not catching a variable via PHPDoc comment [message #1803016] Wed, 20 February 2019 17:47
Eclipse UserFriend
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'];
Previous Topic:PHP Conditionals Formatter
Next Topic:How to use Eclipse for both Java and PHP?
Goto Forum:
  


Current Time: Thu Jul 03 09:57:02 EDT 2025

Powered by FUDForum. Page generated in 1.04641 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top