On Mon, 27 Feb 2012 20:09:08 +0100, Johannes Schlüter
<johan...@schlueters.de> wrote:
On Mon, 2012-02-27 at 13:05 -0600, Richard Lynch wrote:
I'd have to come up with some OTHER scenario not involving fatal
error, such as:
strict $db = new DB();
The example is wrong. The new operator will always return an instance of
the given class (or there will be an exception).
[...]
This is not true. The new operator can return NULL. In fact, the intl
extension uses this extensively:
$ php -d extension=intl.so -r 'var_dump(new Collator());'
Warning: Collator::__construct() expects exactly 1 parameter, 0 given in
Command line code on line 1
NULL
(in fact, I think it's also leaking the object in this case as it should
call zval_dtor before using RETURN_NULL, something I'll look closer to
when I have the time)
Contrast with:
<?php
class A {
function __construct($a) {}
}
var_dump(new A());
Warning: Missing argument 1 for A::__construct(), called in - on line 5
and defined in - on line 3
object(A)#1 (0) {
}
--
Gustavo Lopes
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php