Archive for the ‘Limits’ Category

Strong data typing in PHP, part II: autoboxing and indestructable objects

Wednesday, April 13th, 2011

In an earlier article on the strong typing I’ve described the typehint mechanism that provides data type enforcement for the values sent to the methods and functions. Unfortunately said implementation does not protect against another problem associated with the dynamic typing of variables: a lack of type enforcement when overwritting value of an existing variable.

In order to control the type of data, I decided to introduce to PHP the concept of autoboxing known from other languages such as C# and Java. (more…)