The example below has a syntax error because of the following code:
"another_key" => [ 2 => self::$someStr ] Using something such as:
"another_key" => [ 2 => "bar" ] Is correct syntax. Is there any way to access $someStr instead of hard coding the string?
<?php class Foo { protected static $someStr = 'bar'; private static $arr = [ "some_key" => [ 1 ], "another_key" => [ 2 => self::$someStr ] ]; }
[Property] declaration may include an initialization, but this initialization must be a constant value -- that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.Usingself::$someStrrequires run-time evaluation