You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.
So it took me two days to parse through the code base and get this simple code that still produces the same error. I do not understand pthreads enough to know why this is happening. It's not possible for me to re-arrange where classes are loaded as the actual project code is using an autoloader but I did notice if the require for MyClass is moved to the top level it behaves as expected or if the MyClass definition is put directly into the test script the correct behavior is achieved. Additionally, if the MyTrait definition is moved above the MyWork definition it works as expected as well, regardless of where MyClass is or how it is accessed.
Test Script:
<?php
class MyWork extends \Collectable {
use \MyTrait;
public function run() {
$this->getSomething();
}
}
trait MyTrait {
protected function getSomething($test = false) {
if (!$test) {
require_once 'MyClass.php';
(new \MyClass())->doSomething();
}
}
}
$pool = new \Pool(1, \Worker::class);
$pool->submit(new MyWork());
sleep(5);
$pool->collect(function($work) {
print_r($work->getTerminationInfo());
});
MyClass.php:
<?php
class MyClass {
use \MyTrait;
public function doSomething() {
$this->getSomething(true);
print 'DID SOMETHING';
}
}
Running the test script results in the worker thread throwing PHP Fatal error: Call to protected method MyClass::getSomething() from context 'MyClass'
The text was updated successfully, but these errors were encountered:
So it took me two days to parse through the code base and get this simple code that still produces the same error. I do not understand pthreads enough to know why this is happening. It's not possible for me to re-arrange where classes are loaded as the actual project code is using an autoloader but I did notice if the require for MyClass is moved to the top level it behaves as expected or if the MyClass definition is put directly into the test script the correct behavior is achieved. Additionally, if the MyTrait definition is moved above the MyWork definition it works as expected as well, regardless of where MyClass is or how it is accessed.
Test Script:
MyClass.php:
Running the test script results in the worker thread throwing
PHP Fatal error: Call to protected method MyClass::getSomething() from context 'MyClass'
The text was updated successfully, but these errors were encountered: