mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 06:55:29 +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
|
//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)");
|
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 = Timings::getEventTimings($this);
|
||||||
$timings->startTiming();
|
$timings->startTiming();
|
||||||
|
@ -38,7 +38,7 @@ class HandlerList{
|
|||||||
private array $affectedHandlerCaches = [];
|
private array $affectedHandlerCaches = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @phpstan-param class-string<covariant Event> $class
|
* @phpstan-param class-string<Event|AsyncEvent> $class
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $class,
|
private string $class,
|
||||||
|
@ -38,7 +38,7 @@ class HandlerListManager{
|
|||||||
private array $allLists = [];
|
private array $allLists = [];
|
||||||
/**
|
/**
|
||||||
* @var RegisteredListenerCache[] event class name => cache
|
* @var RegisteredListenerCache[] event class name => cache
|
||||||
* @phpstan-var array<class-string<Event>, RegisteredListenerCache>
|
* @phpstan-var array<class-string<Event|AsyncEvent>, RegisteredListenerCache>
|
||||||
*/
|
*/
|
||||||
private array $handlerCaches = [];
|
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{
|
private static function isValidClass(\ReflectionClass $class) : bool{
|
||||||
$tags = Utils::parseDocComment((string) $class->getDocComment());
|
$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{
|
private static function resolveNearestHandleableParent(\ReflectionClass $class) : ?\ReflectionClass{
|
||||||
for($parent = $class->getParentClass(); $parent !== false; $parent = $parent->getParentClass()){
|
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[]
|
* @return RegisteredListener[]
|
||||||
*/
|
*/
|
||||||
|
@ -692,9 +692,8 @@ class PluginManager{
|
|||||||
/**
|
/**
|
||||||
* @param string $event Class name that extends Event and AsyncEvent
|
* @param string $event Class name that extends Event and AsyncEvent
|
||||||
*
|
*
|
||||||
* @phpstan-template TEvent of AsyncEvent
|
* @phpstan-param class-string<AsyncEvent> $event
|
||||||
* @phpstan-param class-string<TEvent> $event
|
* @phpstan-param \Closure(AsyncEvent) : Promise<null> $handler
|
||||||
* @phpstan-param \Closure(TEvent) : Promise<null> $handler
|
|
||||||
*
|
*
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
@ -719,8 +718,7 @@ class PluginManager{
|
|||||||
/**
|
/**
|
||||||
* Check if the given handler return type is async-compatible (equal to Promise)
|
* Check if the given handler return type is async-compatible (equal to Promise)
|
||||||
*
|
*
|
||||||
* @phpstan-template TEvent of Event&AsyncEvent
|
* @phpstan-param \Closure(AsyncEvent) : Promise<null> $handler
|
||||||
* @phpstan-param \Closure(TEvent) : Promise<null> $handler
|
|
||||||
*
|
*
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user