DOMDocument::load* return values

[email protected] (Chris Wright)
Newsgroups php.internals
Message-ID <CAGAGxbaeQ_SxqwREd0QD05755ENLC5b1ct=DtXB5esagxT2LgA@mail.gmail.com>
All

The return value of the DOMDocument::load* family of methods currently
varies depending on whether it was invoked statically or as an
instance method - when invoked on an instance it returns bool, and
when invoked statically it returns the implicitly created instance or
FALSE on error. Invoking statically also emits an E_STRICT, because it
is an instance method (see: http://3v4l.org/JIRQn).

As a result, I regularly find myself writing something like this:

    $doc = new DOMDocument;
    $doc->loadXML($xml);

I propose that the success return value be changed to the instance
regardless of how it was invoked, which would allow one to write this:

    $doc = (new DOMDocument)->loadXML($xml);

...which has the same effect as invoking it statically, without
provoking the E_STRICT. This would be a very minor BC break (it would
only break code that compares the return value with === TRUE, the
failure return value would be unaffected).

Thoughts, anyone? Would a minor change such as this require an RFC?

Thanks, Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.