#36538 [Opn->Bgs]: Different integer values for XmlReader node types
| From: | rrichards@php.net | Date: | Mon, 27 Feb 2006 14:04:04 +0000 |
| Subject: | #36538 [Opn->Bgs]: Different integer values for XmlReader node types | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-93707@lists.php.net to get a copy of this message | ||
ID: 36538
Updated by: rrichards@php.net
Reported By: paul at stunning-stuff dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Win XP Pro SP2
PHP Version: 5.1.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
They are numbered that way as that is how they are defined in the
underlying library as well as the fact that XMLReader is based on the
.NET implementation (where the types are numbered the same)
Previous Comments:
------------------------------------------------------------------------
[2006-02-26 22:26:14] paul at stunning-stuff dot com
Description:
------------
Hi,
I was fooling around with the XmlReader class and I just thought to
myself... Why are the values of the node type constants 1 to 17. Why
not use 1, 2, 4, 8, 16, 32, 64, etc.
This way you could use bitwise operators:
while ($xmlReader->read())
{
switch ($xmlReader->nodeType)
{
case XmlReader::ELEMENT:
// Do stuff.
break;
case XmlReader::END_ELEMENT:
// Do stuff.
break;
case (XmlReader::TEXT | XmlReader::CDATA):
// Do stuff for text nodes and cdata nodes.
break;
}
}
This would improve readability of the code in many cases. This type of
change could be done to other constants used in other classes/functions
as well to improve their usability (can't think of any at the moment
though).
Also, this type of change shouldn't cause anyone's (decent) code to
break.
Thanks,
Paul
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36538&edit=1