mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
fix PHPstan
This commit is contained in:
parent
eb9814197b
commit
c1e3903934
@ -51,9 +51,6 @@ abstract class Event{
|
||||
//this exception will be caught by the parent event call if all else fails
|
||||
throw new \RuntimeException("Recursive event call detected (reached max depth of " . self::MAX_EVENT_CALL_DEPTH . " calls)");
|
||||
}
|
||||
if($this instanceof AsyncEvent){
|
||||
throw new \InvalidArgumentException("Cannot call async event synchronously, use callAsync() instead");
|
||||
}
|
||||
|
||||
$timings = Timings::getEventTimings($this);
|
||||
$timings->startTiming();
|
||||
|
@ -38,7 +38,7 @@ class HandlerList{
|
||||
private array $affectedHandlerCaches = [];
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<covariant Event> $class
|
||||
* @phpstan-param class-string<Event|AsyncEvent> $class
|
||||
*/
|
||||
public function __construct(
|
||||
private string $class,
|
||||
|
@ -38,7 +38,7 @@ class HandlerListManager{
|
||||
private array $allLists = [];
|
||||
/**
|
||||
* @var RegisteredListenerCache[] event class name => cache
|
||||
* @phpstan-var array<class-string<Event>, RegisteredListenerCache>
|
||||
* @phpstan-var array<class-string<Event|AsyncEvent>, RegisteredListenerCache>
|
||||
*/
|
||||
private array $handlerCaches = [];
|
||||
|
||||
@ -59,7 +59,7 @@ class HandlerListManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param \ReflectionClass<Event> $class
|
||||
* @phpstan-param \ReflectionClass<Event|AsyncEvent> $class
|
||||
*/
|
||||
private static function isValidClass(\ReflectionClass $class) : bool{
|
||||
$tags = Utils::parseDocComment((string) $class->getDocComment());
|
||||
@ -67,9 +67,9 @@ class HandlerListManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param \ReflectionClass<Event> $class
|
||||
* @phpstan-param \ReflectionClass<Event|AsyncEvent> $class
|
||||
*
|
||||
* @phpstan-return \ReflectionClass<Event>|null
|
||||
* @phpstan-return \ReflectionClass<Event|AsyncEvent>|null
|
||||
*/
|
||||
private static function resolveNearestHandleableParent(\ReflectionClass $class) : ?\ReflectionClass{
|
||||
for($parent = $class->getParentClass(); $parent !== false; $parent = $parent->getParentClass()){
|
||||
@ -113,7 +113,7 @@ class HandlerListManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<covariant Event> $event
|
||||
* @phpstan-param class-string<Event|AsyncEvent> $event
|
||||
*
|
||||
* @return RegisteredListener[]
|
||||
*/
|
||||
|
@ -692,9 +692,8 @@ class PluginManager{
|
||||
/**
|
||||
* @param string $event Class name that extends Event and AsyncEvent
|
||||
*
|
||||
* @phpstan-template TEvent of AsyncEvent
|
||||
* @phpstan-param class-string<TEvent> $event
|
||||
* @phpstan-param \Closure(TEvent) : Promise<null> $handler
|
||||
* @phpstan-param class-string<AsyncEvent> $event
|
||||
* @phpstan-param \Closure(AsyncEvent) : Promise<null> $handler
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
@ -719,8 +718,7 @@ class PluginManager{
|
||||
/**
|
||||
* Check if the given handler return type is async-compatible (equal to Promise)
|
||||
*
|
||||
* @phpstan-template TEvent of Event&AsyncEvent
|
||||
* @phpstan-param \Closure(TEvent) : Promise<null> $handler
|
||||
* @phpstan-param \Closure(AsyncEvent) : Promise<null> $handler
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user