Dear List,

I realized the other day that ReflectionFile is missing from the Reflection
API.

A search for "ReflectionFile" on Google will reveal a number of
implementations of classes with exactly that name, which suggests users are
missing this - for example:

https://github.com/rmccue/ReflectionFile/blob/master/ReflectionFile.php

I think reflecting on files used to be less important than it is now - with
the addition of namespaces, and the ability to import classes and
interfaces from other namespaces, there are some interesting and useful
aspects of files that could be exposed via Reflection.

One thing that comes to mind, is with custom annotation libraries for PHP -
some libraries (such as my own) permit you to globally set custom aliases
to make annotation-names shorter and more useful, others resort to making
you type the fully qualified class-name every time you want to apply an
annotation. Neither approach is very elegant. This is addressed by the
language, by allowing you to import classes and interfaces - annotation
libraries could discover imported annotation types this way, but that
aspect of the source code is not exposed via Reflection.

Any thoughts?

- Rasmus Schultz

Reply via email to