Jun
13

Open Source PHP Projects and E_STRICT

Programming No Comments

PHP 5 included a new error reporting directive, E_STRICT, which according to the manual allows PHP to “suggest changes to your code which will ensure the best interoperability and forward compatibility“.

Basically it catches things that have been deprecated (such as call-time pass-by-reference) or are technically incorrect (such as calling a static method in a non-static way, and vice-versa).

I have this enabled on my development and production servers. Mainly because I want to know when I do something stupid like call a static method incorrectly, but also because I’m a PHP purist and believe the PHP error log shouldn’t contain anything unless explicitly put there by the application.

Recently I’ve noticed that numerous PHP applications and libraries emit all kinds of E_STRICT notices. Offenders noted so far are ADOdb, Smarty, WordPress, Plogger and Gallery v2.

All of these are fanastic projects but the fact the code within them emits E_STRICT notices means they’re harder for me to implement and use. I usually end up having to globally search replace something, or call error-reporting() to set a lower error reporting level. The latter is made a lot harder when the application has multiple entry points (e.g. WordPress and Plogger).

The reasons behind these E_STRICT notices are usually due to the project remaining backwardly compatible with PHP4. Especially with regard to call-time pass-by-reference, as this was used extensively in PHP4 to speed up code execution when passing objects around. However the incorrect calling of a static method is a different story, it’s just sloppy OOP in my opinion. Simply testing with E_STRICT turned on would highlight these and fixing them would save a lot of headaches for those of us who run servers with E_STRICT turned on.

Alas, for that to happen we’d need projects to forego the backward compatibility with PHP4, and that is extremely unlikely. No large project with any sense is going to tear their community in two because of people like me harping on about E_STRICT.

Our only hope is for new projects to spring up focused solely on PHP5 and “proper” OOP…

No Comments Yet

Leave a comment

required

required (not published)