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.
When assigning another object in the class constructor, the resource is lost.
Reproducing Code
$customSocket = new CustomSocket();
$exampleThread = new ExampleThread($customSocket);
class CustomSocket {
public $socket;
public function __construct()
{
$this->socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
}
}
class ExampleThread extends Thread {
public $localCustomSocket;
public $localSocket;
public function __construct(CustomSocket $customSocket)
{
var_dump($customSocket);
$this->localCustomSocket = $customSocket;
var_dump($this->localCustomSocket);
$constructorCustomSocket = $customSocket;
var_dump($constructorCustomSocket);
$this->localSocket = $customSocket->socket;
var_dump($this->localSocket);
}
}
Expected Output
object(CustomSocket)#1 (1) {
["socket"]=>
resource(5) of type (Socket)
}
object(CustomSocket)#3 (1) {
["socket"]=>
resource(5) of type (Socket)
}
object(CustomSocket)#1 (1) {
["socket"]=>
resource(5) of type (Socket)
}
resource(5) of type (Socket)
Actual Output
object(CustomSocket)#1 (1) {
["socket"]=>
resource(5) of type (Socket)
}
object(CustomSocket)#3 (1) {
["socket"]=>
int(0)
}
object(CustomSocket)#1 (1) {
["socket"]=>
resource(5) of type (Socket)
}
resource(5) of type (Socket)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Environment
Summary
When assigning another object in the class constructor, the resource is lost.
Reproducing Code
Expected Output
Actual Output
The text was updated successfully, but these errors were encountered: