|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-02-27 15:04 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 23 16:00:01 2025 UTC |
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