parent
c7bdfd883d
commit
29fcf06482
6 changed files with 184 additions and 0 deletions
@ -0,0 +1,34 @@ |
||||
--TEST-- |
||||
Assign by reference to late-static-bound property resolves to called class |
||||
--FILE-- |
||||
<?php |
||||
use native_types; |
||||
|
||||
class Base { |
||||
protected static int $value = 1; |
||||
|
||||
public static function bump(): void { |
||||
$ref = &static::$value; |
||||
$ref = 99; |
||||
} |
||||
|
||||
public static function show(): void { |
||||
var_dump(static::$value); |
||||
} |
||||
} |
||||
|
||||
class Child extends Base { |
||||
protected static int $value = 2; |
||||
} |
||||
|
||||
function main(): void { |
||||
Base::show(); |
||||
Child::bump(); |
||||
Child::show(); |
||||
Base::show(); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
int(1) |
||||
int(99) |
||||
int(1) |
||||
@ -0,0 +1,41 @@ |
||||
--TEST-- |
||||
Assign by reference to native typed static property (self / static / class name) |
||||
--FILE-- |
||||
<?php |
||||
use native_types; |
||||
|
||||
class Test |
||||
{ |
||||
private static int $value = 123; |
||||
|
||||
public static function abc(): void |
||||
{ |
||||
$a = &self::$value; |
||||
var_dump($a); |
||||
$a = 456; |
||||
var_dump(self::$value); |
||||
|
||||
$b = &static::$value; |
||||
var_dump($b); |
||||
$b = 789; |
||||
var_dump(static::$value); |
||||
|
||||
$c = &Test::$value; |
||||
var_dump($c); |
||||
$c = 1000; |
||||
var_dump(Test::$value); |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
Test::abc(); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
int(123) |
||||
int(456) |
||||
int(456) |
||||
int(789) |
||||
int(789) |
||||
int(1000) |
||||
@ -0,0 +1,36 @@ |
||||
--TEST-- |
||||
Assign by reference to parent static property (parent::$value) |
||||
--FILE-- |
||||
<?php |
||||
|
||||
class Base |
||||
{ |
||||
public static $value = 1; |
||||
} |
||||
|
||||
class Child extends Base |
||||
{ |
||||
public static function run() |
||||
{ |
||||
$ref = &parent::$value; |
||||
var_dump(parent::$value); |
||||
var_dump(Child::$value); |
||||
$ref = 999; |
||||
var_dump(parent::$value); |
||||
var_dump(Child::$value); |
||||
var_dump(Base::$value); |
||||
} |
||||
} |
||||
|
||||
function main() |
||||
{ |
||||
Child::run(); |
||||
} |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
int(1) |
||||
int(1) |
||||
int(999) |
||||
int(999) |
||||
int(999) |
||||
@ -0,0 +1,40 @@ |
||||
--TEST-- |
||||
Assign by reference to static property (self / static / class name) |
||||
--FILE-- |
||||
<?php |
||||
|
||||
class Test |
||||
{ |
||||
private static $value = 123; |
||||
|
||||
public static function abc(): void |
||||
{ |
||||
$a = &self::$value; |
||||
var_dump($a); |
||||
$a = 456; |
||||
var_dump(self::$value); |
||||
|
||||
$b = &static::$value; |
||||
var_dump($b); |
||||
$b = 789; |
||||
var_dump(static::$value); |
||||
|
||||
$c = &Test::$value; |
||||
var_dump($c); |
||||
$c = 1000; |
||||
var_dump(Test::$value); |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
Test::abc(); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
int(123) |
||||
int(456) |
||||
int(456) |
||||
int(789) |
||||
int(789) |
||||
int(1000) |
||||
Loading…
Reference in new issue