PHP5: Exception not correctly thown with __get, __set and __toString

From: Date: Mon, 02 Feb 2004 15:33:45 +0000
Subject: PHP5: Exception not correctly thown with __get, __set and __toString
Groups: php.internals 
Request: Send a blank email to internals+get-7473@lists.php.net to get a copy of this message
Hello, The following code does not work as expected: <? class Test { function __get($n) { print('[get]'); throw new Exception('get'); print('[/get]'); // not printed: OK } } print('[test]'); $o = new Test(); $v = $o->foo; print('[/test]'); // printed: bug ?> '/get' is not printed, so the throw statement is correctly executed, but '/test' is printed, so the exception is not correctly "propagated" to the caller. Note that the exception will be thrown later, either: * if the call to __get was not in a function: end of script, * if the call to __get was within a function: end of the function, except if antoher exception is thrown, but in that case the get exception is reported, not the newly thrown one. Same behaviour with __set and __toString. Apparently no problems with __construct, __destruct, __call and __clone. Regards, Stephane

« previous php.internals (#7473) next »