Re: Execution order of PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew Ballard wrote:
I'm not sure you would want to assign null to $client->system. After
all, __set() might not be defined.

I agree with Rob here. If order is really crucial, then call the
statements in the correct order:

<?php

/**
 * causes $client to call __get() in order to resolve
 * 'system'
 */
$system = $client->system;


/**
 * You should add some handling here to make sure that
 * $system is really an object that implements your
 * multiCall() method, and not something else (like null).
 */


$system->multiCall(
    $client->methodOne(),
    $client->methodTwo()
);

?>

I agree with both of you. If you want it ironclad and you cannot change the API, then this is how I would do it. The point is that I _can_ change the API, but I like how simple it looks. The backup plan is to do something like:

$client->system->multiCall(
	$client->__defer()->methodOne(),
	$client->__defer()->methodTwo()
);

The only problem with this is that I'm polluting the $client 'namespace' with a __defer method. And it looks less clean... :)

Now if the consensus is that you absolutely cannot rely on the execution order in this case (not for the order in which function parameters are evaluated, I don't care about that) then I will just change my API and remember with fondness what I could not have...


regards,
Auke van Slooten
Muze

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux