php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72166 Empty SimpleXML elements
Submitted: 2016-05-05 15:00 UTC Modified: 2016-05-05 22:43 UTC
From: rmoisto at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
27 - 23 = ?
Subscribe to this entry?

 
 [2016-05-05 15:00 UTC] rmoisto at gmail dot com
Description:
------------
Creating a SimpleXMLElement on a soap envelope should not result in an empty object. It makes no sense.

Also, now that I looked it up, empty SimpleXML objects cast to boolean will be false. That's so random and stupid. Why? ALL other objects cast to true.

Test script:
---------------
https://3v4l.org/vejJM


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-05 22:43 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-05-05 22:43 UTC] requinix@php.net
SimpleXML does a lot of "magic" with some PHP behaviors. Most of it depends on the current working namespace, which is initially ""; methods like children() and attributes() will return a new object with a different namespace.

Dumping the contents of the object will only show you XML nodes within the current namespace.
https://3v4l.org/Nmf0G

An object's boolean value depends on whether there are XML nodes in the current namespace.
https://3v4l.org/6YOWK
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC