fix PHPstan

This commit is contained in:
ShockedPlot7560 2023-10-22 15:18:39 +02:00
parent c250bb0da7
commit 58155a77fb
No known key found for this signature in database
GPG Key ID: D7539B420F1FA86E
3 changed files with 13 additions and 1 deletions

View File

@ -120,7 +120,7 @@ final class AsyncEventDelegate extends Event{
}
/**
* @phpstan-return Promise<null>
* @phpstan-return Promise<array<int, null>>
*/
private function waitForPromises() : Promise{
$array = $this->promises->toArray();

View File

@ -56,6 +56,11 @@ abstract class Event{
});
}
/**
* @template T
* @phpstan-param \Closure() : T $closure
* @phpstan-return T
*/
final protected function callDepth(\Closure $closure) : mixed{
if(self::$eventCallDepth >= self::MAX_EVENT_CALL_DEPTH){
//this exception will be caught by the parent event call if all else fails

View File

@ -28,8 +28,12 @@ use pocketmine\promise\Promise;
use pocketmine\timings\TimingsHandler;
class RegisteredAsyncListener extends RegisteredListener{
/** @phpstan-var Promise<null> $returnPromise */
private Promise $returnPromise;
/**
* @phpstan-param \Closure(AsyncEvent&Event) : Promise<null> $handler
*/
public function __construct(
\Closure $handler,
int $priority,
@ -51,6 +55,9 @@ class RegisteredAsyncListener extends RegisteredListener{
return !$this->noConcurrentCall;
}
/**
* @phpstan-return Promise<null>
*/
public function callAsync(AsyncEvent&Event $event) : Promise{
$this->callEvent($event);
return $this->returnPromise;