-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constants with a namespace are not added to Namespace_ #156
Comments
* open issue with constants in namespace in lib phpDocumentor/reflection (phpDocumentor/Reflection#156)
That's odd; I thought and tested this.. at least the former issue |
@mvriel Adding On a second thought - the |
Maybe special expressions with Something like: private function determineFqsen(?Context $context, Arg $name) : Fqsen
{
$namespace = $context ? $context->getNamespace() : '';
$evaluator = new ConstExprEvaluator(function(Expr $expr) use ($namespace) {
if ($expr instanceof Namespace_) {
return $namespace;
}
return ''; // or throw Exception
});
$nameString = $evaluator->evaluateSilently($name->value);
if (strpos($nameString, '\\') === false) {
return new Fqsen(sprintf('\\%s', $nameString));
}
return new Fqsen(sprintf('%s', $nameString));
} Not sure how common those special expressions are and if you want to support them. |
About the expressions, let's be a bit pragmatic with that. If somebody reports this as an issue we might want to support it. although we are never able to support everything that people can put in there. Because PHP allows dynamically defined constants and this library is only doing static analysis on the code. Thank you for reaching out and thanks again for creating a patch. We do appreciate that a lot. |
Only Class based Constants are currently recognized and added to the
Namespace_
.Constants in a namespace are ignored:
Reflection/src/phpDocumentor/Reflection/Php/ProjectFactory.php
Line 151 in dc65630
Also Constants defined e.g. via
define('GLOBAL_CONST', 1)
in a namespace\Example
are wrongly attributed to this namespace. FQSEN should be\GLOBAL_CONST
.Those Constants have to be explicitly defined with the current Namespace - e.g.:
The text was updated successfully, but these errors were encountered: