<?php
class foo
{
static function bar()
{
echo self::class, ' vs ', static::class, PHP_EOL;
}
static function bar1()
{
echo self::class, ' vs ', static::class, PHP_EOL;
}
}
class baz extends foo
{
static function bar()
{
echo self::class, ' vs ', static::class, PHP_EOL;
}
}
$r = new ReflectionClass('baz');
$m = $r->getMethod('bar1'); // without overriden method - it's ok, our static scope is preserved. Out: foo vs baz
$m->invoke(null);
$r = new ReflectionClass('baz');
$m = $r->getMethod('bar'); // with overriden method it's impossible to call parent static method. Out: baz vs baz
$m->invoke(null);
// how to statically call the parent static method bar() with scope == baz??
- Output for 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- foo vs baz
baz vs baz
preferences:
129.79 ms | 408 KiB | 5 Q