Edit report at https://bugs.php.net/bug.php?id=60833&edit=1
ID: 60833 Updated by: [email protected] Reported by: mario at include-once dot org Summary: self, parent, static behave inconsistently case-sensitive -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 5.4.0RC6 Block user comment: N Private report: N New Comment: Automatic comment on behalf of stas Revision: http://git.php.net/?p=php-src.git;a=commit;h=184db665ebdb6a2717d15e956391f6d88e1d05c6 Log: fix bug #60833 - self, parent, static behave inconsistently case-sensitive Previous Comments: ------------------------------------------------------------------------ [2012-01-21 20:31:19] mario at include-once dot org 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 this bug report at https://bugs.php.net/bug.php?id=60833&edit=1
