- Output for 8.1.28, 8.2.16 - 8.2.19, 8.3.3 - 8.3.7
- int(5) string(1) "a" string(1) "a" ----------- string(1) "b" string(1) "b" ----------- int(5) string(1) "a"
<?php
class A {
private static int $a = 6;
private static function foo(): int
{
return 5;
}
public function run(): void
{
var_dump($this->foo());
var_dump($this::foo());
var_dump(static::foo());
echo "\n-----------\n";
var_dump($this::$a);
var_dump(static::$a);
echo "\n-----------\n";
$other = new static();
var_dump($other->foo());
var_dump($other::foo());
}
}
class B extends A
{
public static string $a = 'b';
public static function foo(): string
{
return "a";
}
}
(new B)->run();