- Output for 8.1.32, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- Callable called: calling this works! Callable called: this also works
<?php
class Foo
{
public static function bar(string $label): void
{
echo "Callable called: $label\n";
}
}
class MyClass
{
private static string $myCallable;
public function myFunc(): void
{
static::$myCallable = \Foo::class . '::bar';
(self::$myCallable)('this also works');
}
}
$myCallable = \Foo::class . '::bar';
$myCallable('calling this works!');
(new MyClass)->myFunc();