PHP RFC on immutability
I recently started exploring the realm of functional programming in PHP and came across the PHP RFC on immutable classes and properties. Simply put, the RFC, short for Request For Comments, which is a means for developers to propose language changes, zeroes in on extending immutability beyond the reach of constant variables which are, only suitable for scalar values.
Immutability, the inability of language constructs to change their values once assigned, is vital to preserving state in functional applications. This concept is central to the paradigm of functional programming as it makes code a lot easier to evaluate and debug.
The current PHP structure does not accommodate features present in functional languages, Haskell and Scala such as data sharing, and lazy evaluation: the workaround for this includes value objects and garbage collection, viable approaches though not as potent as the aforementioned functional language concepts.
PHP however, does allow those who use it to compose pure functions by keenly spotting side effects and side-causes which result from state changes, use small functions in conjunction with value objects to create referential transparency, and use an array of algorithms to handle collections.
The implication of approval of this proposal would make PHP more robust as well as add more organic, stable support for its functional programming environment. Check out the RFC by following this link: https://wiki.php.net/rfc/immutability.