| The reflection tools aren't meant for constant run-time use. "PHP 5 comes with a complete reflection API that adds the ability to reverse-engineer classes, interfaces, functions, methods and extensions. Additionally, the reflection API offers ways to retrieve doc comments for functions, classes and methods." [1] It's an awesome way to generate automatic documentation for big projects. Of course it's possible to use it for other stuff like pointing to a template (though I'll point out that it can be done faster and more obviously by replacing it with a single function call at the end of the method), but "right tool for the job" and all that. There's a very widely understood premise in programming that comments are blocks of text in source code files intended only to be read by humans and have no effect on program execution. When you change the semantics of something so well-defined... God help you. Also worth noting in your sample code is that many ORMs simply query the DB for the schema and cache that result, so you don't need either of those. Merely being able to connect to your database is sufficient. The former comment (@Column) is a nice, short, human-readable format so developers can see what a column is, but having your code execution depend on that is crazy. What happens if someone minified [2] the code? Or ran it through a bytecode accelerator [3]? I'm not going to stop anyone from abusing comments in their own codebase, but I sure as hell won't let this behavior infect mine. [1]: http://www.php.net/manual/en/intro.reflection.php
[2]: Yes, I know that's pointless in server-side source code - doesn't stop it from happening.
[3]: http://www.php.net/manual/en/reflectionclass.getdoccomment.p... |