Jira issue originally created by user @beberlei:
If you have a docblock that ends with an annotation, for example:
it throws a PHP warnings, because issubclassof() requires the $class to be existent.
Fix: Add class_exists($name) before.
Comment created by @beberlei:
Fixed in r6583, first commit \o/
However, I cant change the assignee here now anymore.
Issue was closed with resolution "Fixed"
Comment created by romanb:
Would classexists(..., false) work, too? Because by default class_exists might trigger autoloading and this is sometimes not wanted for performance reasons (if a class does not exist, each call to class_exists might trigger autoload *again for that class, over and over). So if possible, always do class_exists(...., false) unless you really have the intention that autoloading is invoked, then use class*exists(..., true) to make that clear.
Isn't that what the caching is for in the first place?
But yes, there could be another layer that caches the class_exists calls, however then the complete condition has to be extracted into a method (which would probably be good anyhow, since its not readable).
What caching? Probably you misunderstood me. The second parameter of class_exists defaults to true which can have unwanted consequences with ugly autoloaders.
I changed it to class_exists($name, false) and your test still runs fine, so I guess its ok.
Even when you want autoload to be invoked I would recommend using explicitly: classexists($className, true) because that makes it clear that it is intended. I've seen many times that people did not even know that autoload was invoked on classexists :)
Ah ok, well my intention was to use autoloading, because otherwise the code behaves differently when the annotations are loaded and when they are not which is not obvious from the outside I think.
Comment created by chebba:
With class_exists(..., false) it's hard to use this part of library somewhere with custom annotations and autoloading. If we create some custom annotations we always need to load them all before we can use reader.
May be it will be better to autoload annotations with class_exists(..., true), but filter PhpDoc tags? or separate tags and annotations in some way?