From: Operating system: Linux PHP version: 5.4.0RC6 Package: Scripting Engine problem Bug Type: Bug Bug description:self, parent, static behave inconsistently case-sensitive
Description: ------------ "parent" and "self", "static" LSB tokens behave inconsistent when it comes to case-sensitivity. Class names in PHP are case-insensitive, but these three keywords aren't always, as the parser sees them as raw T_STRINGs. That is, you cannot do `SELF::CNST` or `SELF::$VAR` or `SELF::METHOD()` But it's possible to use `constant("SELF::CNST")` or `call_user_func` with uppercase `SELF` keyword. Likewise do you get an error message for `class SELF {}` declarations, even if the other error messages indicate the uppercase class name wasn't reserved. ---- Patch: It's just a matter of exchanging `memcmp` against `strncasecmp` in `zend_get_class_fetch_type`. Not sure if that is a sufficient substition though. It works well, and all comparisons are shadowed by a length check anyway, so little worries about NUL byte length discrepancies. Performance: No idea. This affects the parser, hard to test without memory exhausting script (eval to redeclare classes). But in clang build no measurable difference (again, pointless test with only x10000 runs). ---- Should this be fixed? Well, of course. This might not matter to most people, never run into this myself IIRC, but it does in fact come up as issue occasionally: http://stackoverflow.com/questions/8953208/fatal-error-class-self-not-found Also because it's not mentioned in the manual yet. http://www.php.net/manual/en/language.oop5.late-static-bindings.php (I shall commit a note there myself...) And of course, the whole PHP 5.3 series doesn't support it. But that doesn't mean it shouldn't be normalized in later versions, specifically the upcoming 5.4. ("Never too later to fix a mistake.." bla bla) Test script: --------------- class a { const C = "C"; function __construct() { print SELF::C; } } new a; -- Edit bug report at https://bugs.php.net/bug.php?id=60833&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60833&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60833&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60833&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60833&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60833&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60833&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60833&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60833&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60833&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60833&r=support Expected behavior: https://bugs.php.net/fix.php?id=60833&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60833&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60833&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60833&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60833&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60833&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60833&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60833&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60833&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60833&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60833&r=mysqlcfg