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.
Trying to assign an array to a Threaded object inside of a Threaded object ($this->store["test"][]), results in automatic creation of a Volatile object. The volatile object gets destroyed, as expected, when leaving the thread context.
Is this expected behaviour?
How must I apply type casting to produce the expected output / What do I need to do differently?
Can I expect my workaround to function properly?
Reproducing Code
<?php
$store = new Threaded();
$store["test"] = new Threaded();
$thread = new class($store) extends Thread {
public $store;
public function __construct(Threaded $store)
{
$this->store = $store;
}
public function run()
{
$this->store["test"][] = (array)[1,2,3]; // this results in Volatile object
// Uncomment the follwing lines and the expected output is produced.
// $tmp = $this->store["test"];
// $tmp[] = (array)[1,2,3];
}
};
$thread->start() && $thread->join();
var_dump($store);
?>
object(Threaded)#1 (1) {
["test"]=>
object(Threaded)#2 (0) {
}
}
PHP Fatal error: Uncaught RuntimeException: pthreads detected an attempt to connect to an object which has already been destroyed in /app/test.php:21
Stack trace:
#0 /app/test.php(21): var_dump(Object(Threaded))
#1 {main}
thrown in /app/test.php on line 21
The text was updated successfully, but these errors were encountered:
on a side note, this casting behaviour is a serious pest and I'd love to see it gone... @sirsnyder what do you think of scrapping this and adding something like Threaded::fromArray() / Volatile::fromArray() instead?
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Environment
Summary
Trying to assign an array to a Threaded object inside of a Threaded object ($this->store["test"][]), results in automatic creation of a Volatile object. The volatile object gets destroyed, as expected, when leaving the thread context.
Is this expected behaviour?
How must I apply type casting to produce the expected output / What do I need to do differently?
Can I expect my workaround to function properly?
Reproducing Code
Expected Output
Actual Output
The text was updated successfully, but these errors were encountered: