PHP Classes

Lightly strict declarations

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in

      PHP Classes blog  >  The Secret PHP Optimi...  >  All threads  >  Lightly strict declarations  >  (Un) Subscribe thread alerts  
Subject:Lightly strict declarations
Summary:Great idea
Author:Aziz S. Hussain
Date:2012-06-14 19:31:02
Update:2012-06-15 00:10:09

  1. Lightly strict declarations   Reply   Report abuse  
Picture of Aziz S. Hussain Aziz S. Hussain - 2012-06-14 20:14:37
Your idea of giving the option for object properties to declare the type is a great step of having PHP become a better scripting language.

Most developers, including myself, are already doing so using the property docblock comments, I don't see a reason why allowing such option is in any way a bad idea.

Good article. Just learned about type inference.


  2. Re: Lightly strict declarations   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-06-15 00:10:09 - In reply to message 1 from Aziz S. Hussain
I think the problem is more with the current Zend Engine version that would have to take care of checking value types at run time and so hurt PHP performance.

Now when you use a JIT compiler, those checks happen at compile time, so no performance problems would seem to occur at run time.

I am just afraid that you would probably need to use a lot of type casting with PHP functions as many of them have return type "mixed", which does not help much type inference.