Re: ReflectionContext for imports and namespace
| From: | Andreas Hennings | Date: | Mon, 11 Dec 2017 08:23:38 +0000 |
| Subject: | Re: ReflectionContext for imports and namespace | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101314@lists.php.net to get a copy of this message | ||
>> These side effects would be that the class loader loads files which can
>> break things?
>
>
> Yes. Reflecting over a codebase which contains even just polyfills
> (duplicate classes) can already lead to unexpected crashes. Reflecting over
> non-PSR-2 code can even lead to worse things such as starting a DB
> connection and performing unwanted operations.
>
My own use case avoids this problem.
Instead of randomly scanning anything, you need to tell the annotation
parser explicitly which namespace directory you want to scan.
It is the caller's responsibility that all class files in this
directory are nicely shaped, and can be safely autoloaded.
In fact I did use a userland parser in the past, but then decided that
native reflection is safe with the above assumption.