ID:               16079
 Comment by:       pornel at despammed dot com
 Reported By:      steve dot venable at lmco dot com
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: All
 PHP Version:      4.1.1
 New Comment:

Not fixed in latest snapshot (PHP5.1.0-dev). I was about to file
bugreport about:

class Test1 {
        const test1 = 'foo'.'bar';
}
class Test2 {
        static $test2 = array('foo'.'bar');
}
define('foo','foo');
class Test3 {
        const test3 = foo.'bar';
}

Workaround is to use define() for all string concatenation and then
using these constants as initializers.


Previous Comments:
------------------------------------------------------------------------

[2002-03-14 14:01:32] steve dot venable at lmco dot com

I can understand requiring constants for static initialization.  But
can the parser be modified to support operators on constants for static
initializations?  This is especially true for long strings which I can't
even break at the end of line for readability.  (I almost submitted this
as a bug :)

Examples:
            $v = 1 + 2;   // Okay
     static $s = 1 + 2;   // Fails parse

            $v = "this long "
                 ."string";  // Okay
     static $s = "this long "
                 ."string";  // Fails parse

Since only constants are involved the parser could collapse the
expression without difficulty.  This makes the code much more readable
(again thinking of very long strings).  In my case I'm building an
array of error messages and don't want the array build to occur
everytime the function is called, hence I made it static.




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=16079&edit=1

Reply via email to