You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, congratulations for the great package. I've started working with it today, and it's really a pleasure to use.
I'm having one quick question:
When I parse the AST (for instance using $method->getBodyAst()), the class names I get (from class PhpParser\Node\Name) are not fully qualified (they are not taking into account the use statements declared at the beginning of the file).
I'm wondering if there is any chance I could use this node traverser within BetterReflection. Is this possible? Did I miss something?
(if you are wondering why, I'm working on a code analyzer that translates basic PHP code (a factory method) into an object representing container definition)
The text was updated successfully, but these errors were encountered:
@moufmouf yes, it may be possible to use FindTypeFromAst which takes into account the use statements etc. by providing the LocatedSource. I imagine it looking something like:
$ast = $method->getBodyAst();
// do whatever you're doing to find the `PhpParser\Node\Name` node
$finder = new \BetterReflection\TypesFinder\FindTypeFromAst();
$type = $finder($theNameNode, $method->getLocatedSource(), $method->inNamespace ? $method->getNamespaceName() : '');
(I haven't tested this code, it's just off my head)
Hi guys,
First of all, congratulations for the great package. I've started working with it today, and it's really a pleasure to use.
I'm having one quick question:
When I parse the AST (for instance using
$method->getBodyAst()
), the class names I get (from classPhpParser\Node\Name
) are not fully qualified (they are not taking into account theuse
statements declared at the beginning of the file).In nikic/PHPParser, there is a node traverser that can resolve the FQCN:
https://github.com/nikic/PHP-Parser/blob/master/doc/2_Usage_of_basic_components.markdown#the-nameresolver-node-visitor
I'm wondering if there is any chance I could use this node traverser within BetterReflection. Is this possible? Did I miss something?
(if you are wondering why, I'm working on a code analyzer that translates basic PHP code (a factory method) into an object representing container definition)
The text was updated successfully, but these errors were encountered: