You have access ev (a | i) l. If you used traits to create your class, you MAY be able to do this.
<?php trait Constructor { public function __construct() { echo __METHOD__, PHP_EOL; } } trait Runner { public function run() { echo __METHOD__, PHP_EOL; } } trait Destructor { public function __destruct() { echo __METHOD__, PHP_EOL; } } $className = 'Thread'; $traits = ['Constructor','Destructor','Runner',]; $class = sprintf('class %s { use %s; }', $className, implode(', ', $traits)); eval($class); $thread = new $className; $thread->run();
These outputs ...
Constructor::__construct Runner::run Destructor::__destruct
So, you CAN, but not sure, YOU SHOULD.
source share