php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55230 Wrong return value for getAttribute
Submitted: 2011-07-18 08:07 UTC Modified: 2011-07-18 08:33 UTC
From: evoloshchuk at gmail dot com Assigned: salathe (profile)
Status: Closed Package: XML Reader
PHP Version: 5.3.6 OS: Mac OS X 10.6.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: evoloshchuk at gmail dot com
New email:
PHP Version: OS:

 

 [2011-07-18 08:07 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-18 08:13 UTC] pajoye@php.net
-Type: Bug +Type: Documentation Problem
 [2011-07-18 08:13 UTC] 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:31 UTC] 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:32 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2011-07-18 08:32 UTC] salathe@php.net
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.


 [2011-07-18 08:33 UTC] salathe@php.net
Apologies for the incorrect automated response. The correct one should have been:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Oct 06 20:05:52 2022 UTC