pdt
pdt copied to clipboard
Declared variable used in a subsequently included file is marked as unused
Describe the bug
A variable defined in a page and then only used in a subsequently include
d file, such as a template, is marked as "never used".
Describe the eclipse environment Eclipse Platform Version: 4.15.0.v20200305-0155 PDT 7.1.0.202002212050
Describe your system
- OS: Linux
- Fedora 32
- PHP 7.4.6
- Webserver Version (if related) N/A
- Utilis (composer, php unit, Xdebug etc...)
To Reproduce Steps to reproduce the behavior:
// Main.php
$pageTitle = 'Create User Records in All Databases';
// Include Header
include __DIR__ . '/inc/header_start.html.inc';
// header_start.html.inc
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title><?=$pageTitle?></title>
Expected behavior
$pageTitle
in recognized as being used in /inc/header_start.html.inc
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
The template file has the corresponding, Variable '$pageTitle' is undefined
error, so hopefully the fix would be reciprocal in this case.
Current implementation support only same-file. In general file-includes are never takes into account, so I'm marking as enhancement.
Current implementation support only same-file. In general file-includes are never takes into account, so I'm marking as enhancement.
This is fine. I cannot remove the bug
label myself, though.
When a file uses a variable that's defined elsewhere, I usually start it with
<?php
/**
* @var MyType1 $myVar1
* @var MyType2 $myVar2
*/
When a file uses a variable that's defined elsewhere, I usually start it with
<?php /** * @var MyType1 $myVar1 * @var MyType2 $myVar2 */
Yes, that will also work. So I can do that, I just prefer to not have to do that. :-p