scalar_objects
Extension that adds support for method calls on primitive types in PHP
...It lets developers register handler classes for primitive types such as strings, arrays, integers, booleans, floats, null values, and resources. After registration, a primitive value can call methods through object-like syntax, such as calling a length method on a string. The project is mainly a proof of concept for designing cleaner primitive-type APIs in PHP. It allows API ideas to be prototyped in userland before any proposal for deeper language integration. Overall, it is most useful for PHP language experimentation, API design research, and exploring how object-style operations on scalar values could work.