Topic: xajax and PHP5 Strict Standarts

Hi,

Nowadays many web developer uses PHP5 in strict standarts (ie. error_reporting(E_ALL|E_STRICT)) while in development stage. However xajax code does not strictly compatible with PHP5. There are:

- Assigning the return value of new by reference
- Passing variable by reference
- Using is_a() function instead of instanceof operator
- Calling non-static methods statically

in xajax code.

I understand some of them are required for backward compatibility (eg. is_a()) but they cause bad HTTP response when using PHP5 strict standarts. Since I always use xajax with PHP5, everytime I upgrade xajax  I replace deprecated code blocks with the PHP compatible ones. Another solution may be turning off error_reporting before xajax code and resetting after:

<?php
// xajaxAIO.inc.php
$oldErrorLevel = error_reporting(0);
// xajax code here
error_reporting($oldErrorLevel);
?>

OR

<?php
// myHandler.php
$oldErrorLevel = error_reporting(0);
require_once "path/to/xajax_file.php";
error_reporting($oldErrorLevel);
// rest of my code
?>

Please be aware that as of PHP6 E_STRICT became part of E_ALL which is used by many users even in production environment.

Re: xajax and PHP5 Strict Standarts

Hi,

The 0.6 version of XAJAX is supposed to be fully PHP5 strict compliant...

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: xajax and PHP5 Strict Standarts

Hi,

I wonder whether there is a more or less official E_STRICT compliant build of xajax 0.5 around somewhere? Google's got some results but I don't really want to use a third party modification from some-place-on-the-internet if it's avoidable.

Thanks!

Marc

Re: xajax and PHP5 Strict Standarts

I don't know of a strict release...

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: xajax and PHP5 Strict Standarts

Thanks Ed.

I think the xajax project would greatly benefit from an E_STRICT release of 0.5 because I guess that many developers who use E_STRICT libraries won't give xajax a second look (after they got a screen full of notices) and switch to jQuery or something. -- At least, that's what I'm intending to do, although I really like xajax (did some translations for the 0.2 series).

Can you give me a rough estimate on how much effort it'd be to port 0.5 to PHP5 Strict compliance? I'd love to help out.

Marc

PS: Is there a chance that 0.6 will be released any time soon? I think I read somewhere that this version is going to be PHP5 only.

Re: xajax and PHP5 Strict Standarts

Marc,

I doubt if there will be a strict port 0.5 - a lot of people have done their development under a php 4.x version.

One of the main thrusts of 0.6 is PHP 5 but I cant address any time frame.

Perhaps one of the developers cound comment...

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: xajax and PHP5 Strict Standarts

Out of curiosity, I just did a rudimentary PHP5/E_STRICT version of xajax_0.5_standard. After all, it's not been very difficult.

Changes:

  • removed unneeded references (&)

  • changed is_a() to instanceof

  • added a few static keywords to method declarations

  • replaced var keywords with protected (if enclosed in appropriate docbook comments) or public (if there wasn't a comment, out of caution)

The altered code works with all of the examples and passes the whole test suite (didn't check with the legacy tests though). Besides that, I haven't done a lot of testing.

Now, I have no idea whether it'd be okay to make the package available for download somewhere. Any feedback would be very much appreciated.

Marc

Re: xajax and PHP5 Strict Standarts

I would appeciate an "official" download version.

So, I wait for "xajax-0.5.1-PHP5-strict.tar.gz". :-)

Re: xajax and PHP5 Strict Standarts

xajax 0.6 is strict compliant and should be checked-in source control soon (within the week?)

// Joe

xajax Developer
Connect to me on LinkedIn:
http://www.linkedin.com/in/calledtoconstruct