Reading Koterov’s book "PHP 7 in the Original," he got acquainted with the Reflection API. How the reflections work is written in an extremely accessible and understandable way. But, there is not a single living example where this can be used in practice. So far, the only practical use that I have noted for myself is the generation of documentation. But not only this mechanism was created for this?
For me, as a junior with a fairly small experience, it is very interesting, in what cases are the reflections used when solving work tasks? I would like real, living examples.
- To understand the power and convenience of reflection, you first have to figure out what metaprogramming is and what it is for, as well as the design patterns, because some of them can be implemented using reflection. But in your place I would not be very keen on her, because as far as I know, in php it works extremely slowly. - Axenow
- @Axenow in 7m php reflection is pretty fast, emnip. However, in the absence of such things as attributes (as in the same rtti delfe or sharpe), its use in applied problems is very limited. - teran 1:49 pm
- Well, Kamon, guys, tell me about the applied problems then. That's the whole point of the question! - Roman Andreev Sep
|
1 answer
A good article came out describing the answer to my question with examples. I'll leave it here, can someone come in handy https://habr.com/post/433266/
|