dev.to/mikevarenek
If you are unfamiliar with closures in PHP or have not given much thought to how they work, this blog post
provides an excellent overview of the basics. It provides an accessible introduction to the concept and
demonstrates why closures are useful in everyday PHP development.
Picked by Stefan Priebsch –
"Read this if you want to set the stage for the other two pretty advanced posts we have selected for you
this week."
f2r.github.io
The article explains that PHP closures created inside instance methods implicitly maintain a reference to
the current object, even when the variable $this is not used directly. This subtle aspect of
PHP closures
can affect the lifetime of objects and their runtime behaviour in ways that many developers may not expect.
An improvement will be introduced with PHP 8.6.
Picked by Sebastian Bergmann –
"This concise read that sharpens your
intuition for how small structural choices can affect runtime behavior and code quality."
freek.dev
This post shows how easy it can be in PHP to inspect or interact with an object’s private internals when you
truly need to. More broadly, it uses that example to explain an interesting aspect of PHP itself: visibility
is tied to class scope, and closures can be rebound in a way that opens access without a lot of heavy
machinery.
Picked by Stefan Priebsch –
"We did not select this post because you should access private methods and properties,
but because it demonstrates an elegant way to solve this problem using closures."