PHP4 Consumer - is there one available?

meepbear * meepbear at
Wed Jul 13 05:05:35 PDT 2005

>I indeed saw this message and intended to have a closer look. I don't have
>PHP5 here but know there are quite some differences in the OO. E.g. PHP4
>doesn't support exceptions.
Exceptions in the consumer code is the only involved part that needs to 
change (the server is far easier to backport since it doesn't have any):

function DoSomething() {
  if (some error condition)
    throw new Exception();

function DoSomethingElse() {

should change to:

function DoSomething() {
  if (some error condition)
    return false;

function DoSomethingElse() {
  if (!DoSomething())
    return false;

That should happen for every exception and is for the most part repetitive 
but does require some care to not inadvertantly break anything. As shown in 
the example, if you call a function that currently can throw an exception 
you need to manually "catch" it in PHP 4 code by adding an if-block or 
you'll run into some very strange undefined behavior.

(public|protected|private) function => function
(public|protected|private) $ => var $

PHP 4 doesn't support interfaces but you can just delete it completely. The 
only important thing is that the handler's member functions exist.

The _get/_set functions can just be deleted entirely as well, they're there 
for sanity checking and don't actually do anything besides validate and 
correct input.

>Actually I'm very careful when people claim anything computer related
>would be 'a matter of xx minutes', usually you could use 'quarter hours'
>instead of 'minutes'. But perhaps for him it would be, since he knows the

Maybe I should have added an "assuming you're comfortable with OO-code in 
general and know how exceptions work" disclaimer :).

My intent was to have a completely self-contained piece of code that you can 
build on top of so that you can focus solely on integration rather than 
having to waste time understanding either the spec or my code and that's 
what the callback interface is for. If the spec changes, I update the class, 
you get the new version, replace the two .php files and things just work.

>I asked if there was something to consider. I thought about changes to the
>spec (but haven't taken a close look yet). meepbear, is your consumer
>updated and ready to use with the current version?

The obvious thing to consider is that if you start changing the code, rather 
than using it in the way it was intented to be used, you're going to end up 
wasting a lot of time in the future if you want to re-integrate fixes in 
your code fork (assuming that's even possible). The only guarantee from my 
end is that the external interface won't change so code you write against it 
now and 5 versions from now will still work fine.

So far the response has been that noone is interested in PHP OO-code and 
only wants procedural code so I never started on a PHP 4 branch since I use 
PHP 5 exclusively. The code I posted then supports the spec as of last week 
(before the change), the code I use has the changes and some other fixes but 
I figured it was rather silly to keep putting up code noone intends to use 

More information about the yadis mailing list