Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/AbstractGeneratedProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,35 @@ final protected function proxyCallToMainThread(string $method, array $args)
return $result;
}

/**
* @param mixed[] $args
*
* @return mixed|void
*/
final protected function deferCallToMainThread(string $method, array $args)
{
$input = new Channel(1);
$call = new Call(
$input,
$this->hash,
spl_object_hash($this),
$method,
$args,
);

if ($this->deferredCallHandler instanceof DeferredCallHandler) {
$this->deferredCallHandler->call($call);
$this->deferredCallHandler->commit($this->out);
} else {
$this->out->send($call);
}

$result = $input->recv();
$input->close();

return $result;
}

/**
* @param mixed[] $args
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/InterfaceProxier.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function populateMethod(Node\Stmt\ClassMethod $method): Node\Stmt\ClassM

$methodBody = new Node\Expr\MethodCall(
new Node\Expr\Variable('this'),
$this->isMethodVoid($method) ? ($this->isDeferrable($method) ? 'deferNotifyMainThread' : 'proxyNotifyMainThread') : 'proxyCallToMainThread',
$this->isMethodVoid($method) ? ($this->isDeferrable($method) ? 'deferNotifyMainThread' : 'proxyNotifyMainThread') : ($this->isDeferrable($method) ? 'deferCallToMainThread' : 'proxyCallToMainThread'),
iterator_to_array($this->methodCallArguments($method))
);

Expand Down