Make evaled code/tokens accessible
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
Description
Code like:
<?php
namespace N;
class Cl {}
eval(<<<'EOF'
use N\Cl;
class U {
/**
* @return Cl
*/
public function test() { throw new \Exception(); }
}
EOF);
$u = new \U();
$refl = new \ReflectionMethod($u, 'test');
var_dump($refl->getFileName());
var_dump($refl->getDocComment());
has unusable phpdoc, as it relies on a use N\Cl; statement. The issue is phpdoc can be accessed by reflection - https://3v4l.org/djLIA - but the full evaled code is not accessible thus the use statements required to parse the phpdoc cannot be read.
At least I am unaware of any way to access the evaled code (or parsed tokens).
The ability to resolve phpdoc for classes from eval is important as annotations are used by many production libs (like Doctrine ORM) and also for static analysers.
This is a feature request to make the full evaled code accessible at least via new reflection ReflectionClass::getFileContents() method. If the parsed file tokens are already stored somewhere, providing a method to access the tokens instead of the file source code will be enough.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den im Issue beschriebenen eval- und ReflectionClass-Einstiegspunkten und untersuche, ob der Interpreter evaluierten Quelltext oder geparste Tokens beibehält. Als erledigt gilt die Aufgabe, wenn die Reflection genügend Informationen über den evaluierten Code offenlegt, damit phpdoc using statements aufgelöst werden können, entweder über ReflectionClass::getFileContents() oder eine äquivalente Token-API.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100