我在Eclipse PDT中使用PHP语义分析时遇到了一些问题。在这种情况下,我收到了"未定义变量"警告:
a.php:
<?php
$a = "var";
?>
b.php:
<?php
/* @var $a String */
/* @var $var String */
include a.php;
echo $a; // Eclipse says $a is undefined
$arr = ["var" => "val"];
extract($arr);
echo $var; // Eclipse says $var is undefined
?>
我试图通过PhpDoc语法通知Eclipse这些变量,但它忽略了它
有什么办法可以摆脱警告而不关闭它吗?
这是固定的。您可以在b.php 中编写
/**
* @var string $a
* @var MyClass $otherVar
*/
echo $a; // No warning should be shown as if $a is undefined.
$otherVar-> // Autocomplete will show you MyClass methods and properties.
从评论中读取变量信息仍然在我的待办事项列表中:https://github.com/pdt-eg/Core-Plugin/issues/103
编辑:
PDT Since 5.0有自己的内置语义验证。自5.3起,您可以配置问题严重性(Ingore/Info/Warning/Error)。由于采用了6.0 PEX变量验证器(未使用/未定义)。我们还为验证扩展添加了API(Symfony和Doctrine插件已经使用了它)。