Doc #55230 [Opn->Csd]: Wrong return value for getAttribute

From: Date: Mon, 18 Jul 2011 12:32:08 +0000
Subject: Doc #55230 [Opn->Csd]: Wrong return value for getAttribute
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-6897@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55230&edit=1 ID: 55230 Updated by: salathe@php.net Reported by: evoloshchuk at gmail dot com Summary: Wrong return value for getAttribute -Status: Open +Status: Closed Type: Documentation Problem Package: XML Reader Operating System: Mac OS X 10.6.3 PHP Version: 5.3.6 -Assigned To: +Assigned To: salathe Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2011-07-18 08:31:25] salathe@php.net Automatic comment from SVN on behalf of salathe Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=313381 Log: changelog for xmlreader::getattribute (doc #55230) ------------------------------------------------------------------------ [2011-07-18 08:13:50] pajoye@php.net The documentation is wrong. An attribute can have an empty string as value, so an empty string cannot be used to indicate that the requested attribute does not exist. NULL is used for this purpose, as described in the XmlReader MSDN documentations, which is the specs for the php's xmlreader and writer (see http://msdn.microsoft.com/en-us/library/sxy2cd1w.aspx). Actually we should maybe return NULL for empty value as well. But that could break some code out there. ------------------------------------------------------------------------ [2011-07-18 08:07:31] evoloshchuk at gmail dot com Description: ------------ According to the spec at http://php.net/manual/en/xmlreader.getattribute.php Return Values The value of the attribute, or an empty string if no attribute with the given name is found or not positioned of element. The actual return value in case if no attribute found is NULL, instead of empty string. Test script: --------------- <?php $reader = new XmlReader(); $reader->xml('<?xml version="1.0" encoding="UTF-8"?><a></a>'); $reader->read(); var_dump($reader->getAttribute('x')); ?> Expected result: ---------------- string(0) "" Actual result: -------------- NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55230&edit=1

« previous php.doc.bugs (#6897) next »