Re: PHP5->PHP4 converter (was Re: [PEAR-DEV] Re: [PEPr] Comment on Networking::GeoIP)

From: Date: Wed, 16 Jun 2004 14:45:33 +0000
Subject: Re: PHP5->PHP4 converter (was Re: [PEAR-DEV] Re: [PEPr] Comment on Networking::GeoIP)
References: 1 2 3 4 5 6  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30775@lists.php.net to get a copy of this message
Alan Knowles wrote:
Rather messy = but a nice proof of concept.. http://www.akbkhome.com/svn/akpear/PHP_DownGrade/DownGrade.php Takes Hans's file http://devel.akbkhome.com/svn/index.php/akpear/PHP_DownGrade/tests/test1.php and converts it into php4/pear code... give or take a few beautifier issues..:) http://devel.akbkhome.com/svn/index.php/akpear/PHP_DownGrade/tests/result1.php The theory if someone wants to run with it: package.xml <file generate_php4="yes">test1.php</file> pear package .. generates a file test1.php4 pear install if (your system is php4) =>
    copy test1.php => test1.php5
    copy test1.php4 => test1.php
and heh volia PHP5 packages in pear..
:) Wow. ... But it won't really work with the error handling because you can't convert Exceptions (w/o lots of work!). Every call to a method that throws an Exception would need to check return value & re-return if PEAR::isError($return). E.g. lookupCountryCode() and lookupCountryName() will break if lookupCountryId() returns a PEAR_Error, but they work fine it if throws an Exception. That's a good example of the problem, although in that case I may also change those to return false instead of throw an Exception. Constructor calling open() which may throw Exception is another good example. Or open() calling loadSharedMemory(), etc. etc. Hans

« previous php.pear.dev (#30775) next »