PHP 8.3 quirk with self:: usage in constructor? [closed]

2 days ago 6
ARTICLE AD BOX

I have this code block:

class ExampleService extends BaseService { protected $handler; public const TASK_ONE = 'task_one'; public const TASK_TWO = 'task_two'; public function __construct() { $model = new GenericModel(); $model->setTaskList([ (new GenericTask(self::TASK_ONE)) ->setPriority(0) ->setTaskType(GenericTask::TYPE_IMPORT) ->setCallback([$this->handler, 'runTaskOne']), (new GenericTask(self::TASK_TWO)) ->setPriority(100) ->setTaskType(GenericTask::TYPE_EXPORT) ->setCallback([$this->handler, 'runTaskTwo']), ]); parent::__construct($model); } public static function getInstance() { static $instance; if ($instance === null) { $instance = new self(); } return $instance; } }

my issue is that when i reload the page i get a fatal error on this line

(new GenericTask(self::TASK_ONE))

which says something like "GenericTask is not callable". After hitting my head in the wall a few times and after several debugs and tries i noticed that if i change that self::TASK_ONE to something like static::TASK_ONE or even $this::TASK_ONE then everything works fine

What are the forces at play here? why only self:: fails? Can somebody explain ?

Read Entire Article