|
10 | 10 | */
|
11 | 11 |
|
12 | 12 | use CodeIgniter\Cache\CacheInterface;
|
| 13 | +use CodeIgniter\Config\BaseConfig; |
13 | 14 | use CodeIgniter\Config\Factories;
|
14 | 15 | use CodeIgniter\Cookie\Cookie;
|
15 | 16 | use CodeIgniter\Cookie\CookieStore;
|
|
31 | 32 | use CodeIgniter\Test\TestLogger;
|
32 | 33 | use Config\App;
|
33 | 34 | use Config\Database;
|
| 35 | +use Config\DocTypes; |
34 | 36 | use Config\Logger;
|
35 | 37 | use Config\Services;
|
36 | 38 | use Config\View;
|
|
47 | 49 | */
|
48 | 50 | function app_timezone(): string
|
49 | 51 | {
|
50 |
| - /** @var App $config */ |
51 |
| - $config = config('App'); |
| 52 | + $config = config(App::class); |
52 | 53 |
|
53 | 54 | return $config->appTimezone;
|
54 | 55 | }
|
@@ -203,7 +204,12 @@ function command(string $command)
|
203 | 204 | /**
|
204 | 205 | * More simple way of getting config instances from Factories
|
205 | 206 | *
|
206 |
| - * @return object|null |
| 207 | + * @template ConfigTemplate of BaseConfig |
| 208 | + * |
| 209 | + * @param class-string<ConfigTemplate>|string $name |
| 210 | + * |
| 211 | + * @return ConfigTemplate|null |
| 212 | + * @phpstan-return ($name is class-string<ConfigTemplate> ? ConfigTemplate : object|null) |
207 | 213 | */
|
208 | 214 | function config(string $name, bool $getShared = true)
|
209 | 215 | {
|
@@ -495,7 +501,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
|
495 | 501 | Services::session(null, true)->regenerate(); // @codeCoverageIgnore
|
496 | 502 | }
|
497 | 503 |
|
498 |
| - $baseURL = config('App')->baseURL; |
| 504 | + $baseURL = config(App::class)->baseURL; |
499 | 505 |
|
500 | 506 | if (strpos($baseURL, 'https://') === 0) {
|
501 | 507 | $authority = substr($baseURL, strlen('https://'));
|
@@ -885,7 +891,7 @@ function redirect(?string $route = null): RedirectResponse
|
885 | 891 | */
|
886 | 892 | function _solidus(): string
|
887 | 893 | {
|
888 |
| - if (config('DocTypes')->html5 ?? false) { |
| 894 | + if (config(DocTypes::class)->html5 ?? false) { |
889 | 895 | return '';
|
890 | 896 | }
|
891 | 897 |
|
@@ -973,8 +979,6 @@ function route_to(string $method, ...$params)
|
973 | 979 | * session()->set('foo', 'bar');
|
974 | 980 | * $foo = session('bar');
|
975 | 981 | *
|
976 |
| - * @param string $val |
977 |
| - * |
978 | 982 | * @return array|bool|float|int|object|Session|string|null
|
979 | 983 | * @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null)
|
980 | 984 | */
|
@@ -1064,7 +1068,7 @@ function single_service(string $name, ...$params)
|
1064 | 1068 | */
|
1065 | 1069 | function slash_item(string $item): ?string
|
1066 | 1070 | {
|
1067 |
| - $config = config('App'); |
| 1071 | + $config = config(App::class); |
1068 | 1072 |
|
1069 | 1073 | if (! property_exists($config, $item)) {
|
1070 | 1074 | return null;
|
@@ -1166,10 +1170,8 @@ function timer(?string $name = null, ?callable $callable = null)
|
1166 | 1170 | */
|
1167 | 1171 | function view(string $name, array $data = [], array $options = []): string
|
1168 | 1172 | {
|
1169 |
| - /** @var CodeIgniter\View\View $renderer */ |
1170 | 1173 | $renderer = Services::renderer();
|
1171 | 1174 |
|
1172 |
| - /** @var \CodeIgniter\Config\View $config */ |
1173 | 1175 | $config = config(View::class);
|
1174 | 1176 | $saveData = $config->saveData;
|
1175 | 1177 |
|
|
0 commit comments