Bug 562976 - PHP linter think lambda variable declaration is undefined in it's own declaration?
Summary: PHP linter think lambda variable declaration is undefined in it's own declara...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-08 12:45 EDT by Hans Henrik Bergan CLA
Modified: 2020-05-27 19:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans Henrik Bergan CLA 2020-05-08 12:45:18 EDT
in this code: 
on line 6 it complains that $inner is undefined, despite $inner literally being defined on line 6.

on line 9 it believes $inner is undefined, despite being captured on line 6 for the lambda scope.

screenshot: https://i.imgur.com/3daup13.png

<code>
<?php
// You can't remove DOMNodes from a DOMNodeList as you're iterating over them in a foreach loop.
// https://www.php.net/manual/en/domnode.removechild.php#90292
$domd = new DOMDocument();
$toRemove = [];
$inner = function (DOMNode $domd) use (&$inner, &$toRemove) {
    if ($domd->hasChildNodes()) {
        foreach ($domd->childNodes as $child) {
            $inner($child);
        }
    }
    if ($domd instanceof DOMText) {
        if (0 === strlen(trim($domd->textContent))) {
            $toRemove[] = $domd;
        }
    }
};
$inner($domd);
foreach ($toRemove as $remove) {
    // var_dump($toRemove) & die();
    $remove->parentNode->removeChild($remove);
}
</code>
Comment 1 Hans Henrik Bergan CLA 2020-05-27 19:29:31 EDT
why is this bug moved to z_archived ? per  https://bugs.eclipse.org/bugs/describecomponents.cgi?product=z_Archived 
  z_archived  means "Archived Eclipse.org Projects",

is PDT an EOL/archived project?