Why we should migrate to PHP5

at 2005-02-06 in PHP5 by friebe (0 comments)

Migrating to PHP5 (plain, as released by the PHP team) is currently not possible:

  • Builtin classes like Exception and Iterator take names we've already used.
    So much for BC here. See also entry #16
  • The one-super-class-for-all rule of XP is broken as built-in Exception needs to be the base class of anything that can be throw()n
    I've discussed this earlier, in entry #11
  • Serialization is incompatible
    A class with private and protected members serialized in PHP5 will not be readable by PHP4's serialize(). That prevents us from being able to migrate parts of our web applications relying on a defined session format.

Of course, by using our patch, we can get around the first two of these issues (at least, at its current state). An addition to the patch could also fix up the third.

But let's also have a look at the other side, why it would make sense to upgrade:

  • Dereferencing
    Elegant code as, for example, the following, will work.

    <?php $instance= XPClass::forName('lang.Object')->newInstance();?>


    Another common place where we could really benefit from this is in the logger API. Instead of having to use ugly temporary variables, we could write:

    <?php $this->cat= Logger::getInstance()->getCategory();?>


  • Exceptions
    Exceptions finally work like exceptions should work: The execute stack is jumped over until a catch statement is found.

  • DOM features
    The new DOM extension allows PHP callbacks in XSL. For instance, you can write:
    <xsl:value-of select="php:function('date', 'r')"/> and get Sun, 6 Feb 2005 16:42:12 +0100.

    This could come in handy when needing to check for a user permission within a XMLScriptlet's XSL file and not wanting to load all the permissions into the formresult.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases

Related

Find related articles by a search for «Why».