DOMDocument::load* return values

From: Date: Tue, 16 Sep 2014 12:39:19 +0000
Subject: DOMDocument::load* return values
Groups: php.internals 
Request: Send a blank email to internals+get-77245@lists.php.net to get a copy of this message
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

« previous php.internals (#77245) next »