That looks way too much like Java. PHP is dynamically typed for a reason, and I've come to appreciate certain aspects of it's dynamically-typed nature. If anything, PHP should go more towards a full OO language by automatically creating the necessary objects by declared value type implicitly, like Ruby and Python do - something like this:
Originally Posted by arkinstall
And then all the PHP functions would have to be modified to accept the new base object type as well, like:
$var = "hello"; // automatic string object
$num = 1234; // automatic integer object
$regex = "/(.*)/i"; // automatic regex object
So at least to me, that would be the perfect way to take PHP to the OO-level for those who want it, and keep it looking like flat dynamic variables for those who don't.
$sub = substr($var, 0, 2); // equals "he"
// Also new syntax is provided for the new object types
$sub = $var->substr(0, 2); // equals "he"