Skip to content

Commit 1b2203e

Browse files
committed
Fix generics signature of config() and model()
1 parent 388029c commit 1b2203e

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

system/Common.php

+10-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111

1212
use CodeIgniter\Cache\CacheInterface;
13-
use CodeIgniter\Config\BaseConfig;
1413
use CodeIgniter\Config\Factories;
1514
use CodeIgniter\Cookie\Cookie;
1615
use CodeIgniter\Cookie\CookieStore;
@@ -27,7 +26,6 @@
2726
use CodeIgniter\HTTP\Response;
2827
use CodeIgniter\HTTP\ResponseInterface;
2928
use CodeIgniter\HTTP\URI;
30-
use CodeIgniter\Model;
3129
use CodeIgniter\Session\Session;
3230
use CodeIgniter\Test\TestLogger;
3331
use Config\App;
@@ -202,16 +200,15 @@ function command(string $command)
202200

203201
if (! function_exists('config')) {
204202
/**
205-
* More simple way of getting config instances from Factories
203+
* Simpler way of getting config instances from Factories
206204
*
207-
* @template ConfigTemplate of BaseConfig
205+
* @template T of object
208206
*
209-
* @param class-string<ConfigTemplate>|string $name
207+
* @param class-string<T>|non-empty-string $name
210208
*
211-
* @return ConfigTemplate|null
212-
* @phpstan-return ($name is class-string<ConfigTemplate> ? ConfigTemplate : object|null)
209+
* @phpstan-return ($name is class-string<T> ? T : null)
213210
*/
214-
function config(string $name, bool $getShared = true)
211+
function config(string $name, bool $getShared = true): ?object
215212
{
216213
return Factories::config($name, ['getShared' => $getShared]);
217214
}
@@ -811,16 +808,15 @@ function log_message(string $level, string $message, array $context = [])
811808

812809
if (! function_exists('model')) {
813810
/**
814-
* More simple way of getting model instances from Factories
811+
* Simpler way of getting model instances from Factories
815812
*
816-
* @template ModelTemplate of Model
813+
* @template T of object
817814
*
818-
* @param class-string<ModelTemplate>|string $name
815+
* @param class-string<T>|non-empty-string $name
819816
*
820-
* @return ModelTemplate|null
821-
* @phpstan-return ($name is class-string<ModelTemplate> ? ModelTemplate : object|null)
817+
* @phpstan-return ($name is class-string<T> ? T : null)
822818
*/
823-
function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn = null)
819+
function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn = null): ?object
824820
{
825821
return Factories::models($name, ['getShared' => $getShared], $conn);
826822
}

0 commit comments

Comments
 (0)