- Output for 8.1.0 - 8.1.29, 8.2.0 - 8.2.22, 8.3.0 - 8.3.10
- Protected function called
<?php
class Command{
/** @var callable $code */
private $code;
/**
* @param callable $code
*/
public function setCode(callable $code): static
{
$this->code = $code;
return $this;
}
public function execute(): void
{
($this->code)();
}
}
class CustomCommand extends Command{
public function __construct(){
parent::setCode([$this, 'runCustomCommand']);
}
protected function runCustomCommand(): void
{
echo 'Protected function called';
}
}
$code = new CustomCommand();
$code->execute();