phpDocumentor / Reflection

Reflection library to do Static Analysis for PHP Projects
MIT License
117 stars 51 forks source link

Define statements that are expressions fail to parse #182

Closed mvriel closed 2 years ago

mvriel commented 3 years ago

When you define a global constant as a define with the NAMESPACE magic constant (for example); this library will throw an error:

Notice: Undefined property: PhpParser\Node\Expr\BinaryOp\Concat::$value
strpos() expects parameter 1 to be string, null given

This is because this library assumes that the value of the Define node is always a string; while this is not necessarily true

Example case:

define(__NAMESPACE__ . '\\MY_CONSTANT', 123);