diff --git a/system/Common.php b/system/Common.php index e132d982b7d4..158211032b8b 100644 --- a/system/Common.php +++ b/system/Common.php @@ -773,7 +773,6 @@ function log_message(string $level, string $message, array $context = []) * @param class-string $name * * @return T - * @phpstan-return Model */ function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn = null) { diff --git a/system/Config/Factories.php b/system/Config/Factories.php index 8bcef3e09610..0a6f34d10e27 100644 --- a/system/Config/Factories.php +++ b/system/Config/Factories.php @@ -11,6 +11,7 @@ namespace CodeIgniter\Config; +use CodeIgniter\Database\ConnectionInterface; use CodeIgniter\Model; use Config\Services; @@ -23,7 +24,6 @@ * instantiation checks. * * @method static BaseConfig config(...$arguments) - * @method static Model models(...$arguments) */ class Factories { @@ -67,6 +67,22 @@ class Factories */ protected static $instances = []; + /** + * This method is only to prevent PHPStan error. + * If we have a solution, we can remove this method. + * See https://github.com/codeigniter4/CodeIgniter4/pull/5358 + * + * @template T of Model + * + * @param class-string $name + * + * @return T + */ + public static function models(string $name, array $options = [], ?ConnectionInterface &$conn = null) + { + return self::__callStatic('models', [$name, $options, $conn]); + } + /** * Loads instances based on the method component name. Either * creates a new instance or returns an existing shared instance. @@ -263,7 +279,7 @@ public static function setOptions(string $component, array $values): array /** * Resets the static arrays, optionally just for one component * - * @param string $component Lowercase, plural component name + * @param string|null $component Lowercase, plural component name */ public static function reset(?string $component = null) {