fix style

This commit is contained in:
ShockedPlot7560 2023-10-22 15:06:17 +02:00
parent 9b2b92ac1f
commit b78ff00418
No known key found for this signature in database
GPG Key ID: D7539B420F1FA86E
4 changed files with 7 additions and 7 deletions

View File

@ -42,7 +42,7 @@ final class AsyncEventDelegate extends Event{
/** /**
* @phpstan-return Promise<null> * @phpstan-return Promise<null>
*/ */
public function callAsync() : Promise { public function callAsync() : Promise{
$this->promises->clear(); $this->promises->clear();
return $this->callDepth($this->callAsyncDepth(...)); return $this->callDepth($this->callAsyncDepth(...));
} }
@ -75,7 +75,7 @@ final class AsyncEventDelegate extends Event{
/** /**
* @phpstan-return Promise<null> * @phpstan-return Promise<null>
*/ */
private function callPriority(int $priority) : Promise { private function callPriority(int $priority) : Promise{
$handlers = HandlerListManager::global()->getListFor($this->event::class)->getListenersByPriority($priority); $handlers = HandlerListManager::global()->getListFor($this->event::class)->getListenersByPriority($priority);
/** @phpstan-var PromiseResolver<null> $resolver */ /** @phpstan-var PromiseResolver<null> $resolver */
@ -102,7 +102,7 @@ final class AsyncEventDelegate extends Event{
$resolver->reject(); $resolver->reject();
}); });
}else{ }else{
$this->waitForPromises()->onCompletion(function() use (&$nonConcurrentHandlers, $testResolve) { $this->waitForPromises()->onCompletion(function() use (&$nonConcurrentHandlers, $testResolve){
$handler = array_shift($nonConcurrentHandlers); $handler = array_shift($nonConcurrentHandlers);
if($handler instanceof RegisteredAsyncListener){ if($handler instanceof RegisteredAsyncListener){
$this->promises->add($handler->callAsync($this->event)); $this->promises->add($handler->callAsync($this->event));
@ -122,7 +122,7 @@ final class AsyncEventDelegate extends Event{
/** /**
* @phpstan-return Promise<null> * @phpstan-return Promise<null>
*/ */
private function waitForPromises() : Promise { private function waitForPromises() : Promise{
$array = $this->promises->toArray(); $array = $this->promises->toArray();
$this->promises->clear(); $this->promises->clear();

View File

@ -47,7 +47,7 @@ abstract class Event{
* @throws \RuntimeException if event call recursion reaches the max depth limit * @throws \RuntimeException if event call recursion reaches the max depth limit
*/ */
public function call() : void{ public function call() : void{
$this->callDepth(function() { $this->callDepth(function(){
$handlers = HandlerListManager::global()->getHandlersFor(static::class); $handlers = HandlerListManager::global()->getHandlersFor(static::class);
foreach($handlers as $registration){ foreach($handlers as $registration){

View File

@ -38,7 +38,7 @@ class RegisteredAsyncListener extends RegisteredListener{
private bool $noConcurrentCall, private bool $noConcurrentCall,
TimingsHandler $timings TimingsHandler $timings
){ ){
$handler = function(AsyncEvent&Event $event) use($handler) : void { $handler = function(AsyncEvent&Event $event) use($handler) : void{
$this->returnPromise = $handler($event); $this->returnPromise = $handler($event);
if(!$this->returnPromise instanceof Promise){ if(!$this->returnPromise instanceof Promise){
throw new \TypeError("Async event handler must return a Promise"); throw new \TypeError("Async event handler must return a Promise");

View File

@ -692,7 +692,7 @@ class PluginManager{
* @phpstan-template TEvent of Event * @phpstan-template TEvent of Event
* @phpstan-param (\Closure(TEvent) : void)|(\Closure(AsyncEvent&TEvent) : Promise<null>) $handler * @phpstan-param (\Closure(TEvent) : void)|(\Closure(AsyncEvent&TEvent) : Promise<null>) $handler
*/ */
private function canHandleAsyncEvent(\Closure $handler) : bool { private function canHandleAsyncEvent(\Closure $handler) : bool{
$reflection = new \ReflectionFunction($handler); $reflection = new \ReflectionFunction($handler);
$return = $reflection->getReturnType(); $return = $reflection->getReturnType();