-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
empty() returns false for an empty SimpleXMLElement #3963
Comments
When I set a breakpoint in Zend PHP in sxe_object_cast_ex, the breakpoint is not hit in the first example above but it is hit in the second example. In HHVM, the equivalent breakpoint in sxe_object_cast is hit in both examples. |
Zend has a different call stack when calling |
I will look at it |
This reverts commit ea535b8. Closes facebook#3963. Closes facebook#4119.
The problem is basically this: The PHP documentation states for empty(): However, SimpleXML decides that's nonsense: <?php
$xml = new SimpleXMLElement('<foo><bar/></foo>');
var_dump(isset ($xml->bar)); // true
var_dump((bool)($xml->bar)); // true
var_dump(empty($xml->bar)); // true? wat. Anyone with php internals knowledge that knows what php-src does for figuring out empty() in this case? @sgolemon @auroraeosrose |
In Zend, calling empty() on a nested xml element of a SimpleXMLElement returns true when the element has no text nor children. In HHVM it returns false. For example,
However, in a simpler example, a single element by itself will correctly return true in both Zend and HHVM:
Tested on libxml 2.7.8, HHVM 3.3, and PHP 5.3
// @danslo
The text was updated successfully, but these errors were encountered: