Hash table in PHP – in_array vs isset, SplQueue, SplFixedArray
A PHP array is one of the most-used data types, but few people think about how it works under the hood. A PHP array is actually a hash table – a data structure that allows O(1) element access. I show how it works, what the practical implications are, and where PHP arrays surprise you with their performance characteristics.
- Published in Algorytmy
PHP 7.4 preview – typed properties, arrow functions, spread in arrays, preloading
PHP 7.4 arrives in November 2019 and brings several changes that will have a real impact on everyday code. Typed properties are the headline feature – at last we can declare types directly on class properties. Plus arrow functions, spread in arrays, and the null coalescing assignment operator.
- Published in PHP
Decorator pattern in PHP – composition over inheritance, cached repository example
Inheritance is the simplest way to extend a class – but not always the best. When you want to add several independent features to an object, a class hierarchy quickly becomes unreadable. Decorator lets you wrap objects in layers of functionality without modifying the original and without deep inheritance.
- Published in Wzorce projektowe
DI in Magento 2 – container, Virtual Types, Factory, shared/non-shared
Dependency Injection in Magento 2 looks like magic at first. You type an interface in the constructor and Magento delivers the right implementation. How does it know what to inject? How does DI compilation work? What are virtual types and what are they for? I break it all down.
- Published in Magento / Adobe Commerce
