From abe99a866938c151fd07ff6b853c681ed9ac118f Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 12 Aug 2026 13:13:30 +0200 Subject: [PATCH] fix: specify parameter types for Model when and whenNot methods via @phpstan-type --- system/Model.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/system/Model.php b/system/Model.php index ccade9cfb700..c73cdba448c7 100644 --- a/system/Model.php +++ b/system/Model.php @@ -40,6 +40,11 @@ * * @property-read BaseConnection $db * + * @phpstan-type WhenCallback callable(BaseBuilder, mixed): mixed + * @phpstan-type WhenDefaultCallback callable(BaseBuilder): mixed + * + * @phpstan-import-type row_array from BaseModel + * * @method $this groupBy($by, ?bool $escape = null) * @method $this groupEnd() * @method $this groupStart() @@ -78,15 +83,11 @@ * @method $this selectMax(string $select = '', string $alias = '') * @method $this selectMin(string $select = '', string $alias = '') * @method $this selectSum(string $select = '', string $alias = '') - * @method $this when($condition, callable $callback, ?callable $defaultCallback = null) - * @method $this whenNot($condition, callable $callback, ?callable $defaultCallback = null) + * @method $this when($condition, WhenCallback $callback, ?WhenDefaultCallback $defaultCallback = null) + * @method $this whenNot($condition, WhenCallback $callback, ?WhenDefaultCallback $defaultCallback = null) * @method $this where($key, $value = null, ?bool $escape = null) * @method $this whereIn(?string $key = null, $values = null, ?bool $escape = null) * @method $this whereNotIn(?string $key = null, $values = null, ?bool $escape = null) - * - * @phpstan-method $this when($condition, callable(BaseBuilder, mixed): mixed $callback, (callable(BaseBuilder): mixed)|null $defaultCallback = null) - * @phpstan-method $this whenNot($condition, callable(BaseBuilder, mixed): mixed $callback, (callable(BaseBuilder): mixed)|null $defaultCallback = null) - * @phpstan-import-type row_array from BaseModel */ class Model extends BaseModel {