HomePHP A Final Example of Late Static Bindings in PHP 5.3
A Final Example of Late Static Bindings in PHP 5.3
Late Static Bindings (LSB), a powerful feature bundled with PHP 5.3, are much easier to master than you might think. Achieving intimate knowledge of them requires only an average background in working with objects and classes. This article concludes a six-part series that shows you what you can do with LSB.
So, if you're a developer interested in grasping the key concepts that surround the implementation of LSB, then I recommend you start reading this article series right now. Through its tutorials you'll learn how to take advantage of the functionality offered by LSB to create flexible hierarchies of classes where at least one of their methods will be used in a static context.
Naturally, marketing the numerous benefits provided by LSB is a process that must be complemented in all the cases with some functional and illustrative code. In keeping with this premise, in previous parts of this series I explained how to implement this feature in the construction of a concrete factory class, which thanks to the use of LSB, was provided with the ability to statically create a couple of block-level (X)HTML objects via a static method, not surprisingly called "create()," or at instance level via its pertinent constructor.
In addition, I left off the last article showing the definitions of the classes responsible for originating the aforementioned (X)HTML objects, an easy to follow process. While it's possible to create and manipulate these objects as standalone structures, my goal here is to demonstrate how to bring them to life by using the concrete factory previously defined. In consonance with this, in this last installment of the series I'm going to set up an example that will show how to put all of these classes to work together. This will demonstrate how the clever use of LSB can be of great help when building flexible factory classes.
Ready to learn how this will be done? Then don't waste more time; begin reading!