From:             paul at stunning-stuff dot com
Operating system: Win XP Pro SP2
PHP version:      5.1.2
PHP Bug Type:     Feature/Change Request
Bug description:  Different integer values for XmlReader node types

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 bug report at http://bugs.php.net/?id=36538&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36538&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36538&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36538&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36538&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36538&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36538&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36538&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36538&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36538&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36538&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36538&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36538&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36538&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36538&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36538&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36538&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36538&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36538&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36538&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36538&r=mysqlcfg

Reply via email to