Norway


has written up a that introduces you to PHP’s Reflection API, functionality included with the language that allows for introspection of the code and some -time modifications.

When I started coding, I wasn’t aware of the power of and the main reason is that I didn’t need it to design my simple class, module or even my package, then I started to find it in many areas playing a role. So in this part we will introduce Reflection API.

The post is then broken down into a few sections covering the basics of the Reflection functionality, examples of it in use and some other references you can use to get more information. Code examples are included to show how to use the API to do things like:

  • get the parent class for a current class
  • get the docblock comment of a method
  • making private methods available for testing

He also links to two packages that make use of the Reflection API heavily to generate documentation and build a dependency injection container.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here