This project reproduces the issue when using static members in PHP threads. For some reason, the static members of a class is not accessible when accessed in thread context (e.g: \Thread::run() method).
require 'MyClass.php';
require 'MyThread.php';
var_dump(MyClass::$data); // prints the array properly
$thread = new MyThread();
$thread->start() && $thread->join();array(2) {
["foo"]=>
string(3) "bar"
["bar"]=>
string(3) "baz"
}
array(2) {
["foo"]=>
string(3) "bar"
["bar"]=>
string(3) "baz"
}array(2) {
["foo"]=>
string(3) "bar"
["bar"]=>
string(3) "baz"
}
NULLRun the below code to create an image with PHP 5.6 with pthreads enabled.
$ docker build --rm -t pthreads:php56 .
Run the below code to create an image with PHP 7 with pthreads enabled.
$ docker build --rm -f Dockerfile.php7 -t pthreads:php7 .
$ ./php56 sample.php
$ ./php7 sample.php