Skip to content

Commit 5726eba

Browse files
authored
Merge pull request #7224 from maniaba/develop
refactor: Update PHPDoc Common::config
2 parents 4a4f55b + 5f19ad9 commit 5726eba

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

system/Common.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
use CodeIgniter\Cache\CacheInterface;
13+
use CodeIgniter\Config\BaseConfig;
1314
use CodeIgniter\Config\Factories;
1415
use CodeIgniter\Cookie\Cookie;
1516
use CodeIgniter\Cookie\CookieStore;
@@ -31,6 +32,7 @@
3132
use CodeIgniter\Test\TestLogger;
3233
use Config\App;
3334
use Config\Database;
35+
use Config\DocTypes;
3436
use Config\Logger;
3537
use Config\Services;
3638
use Config\View;
@@ -47,8 +49,7 @@
4749
*/
4850
function app_timezone(): string
4951
{
50-
/** @var App $config */
51-
$config = config('App');
52+
$config = config(App::class);
5253

5354
return $config->appTimezone;
5455
}
@@ -203,7 +204,12 @@ function command(string $command)
203204
/**
204205
* More simple way of getting config instances from Factories
205206
*
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)
207213
*/
208214
function config(string $name, bool $getShared = true)
209215
{
@@ -495,7 +501,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
495501
Services::session(null, true)->regenerate(); // @codeCoverageIgnore
496502
}
497503

498-
$baseURL = config('App')->baseURL;
504+
$baseURL = config(App::class)->baseURL;
499505

500506
if (strpos($baseURL, 'https://') === 0) {
501507
$authority = substr($baseURL, strlen('https://'));
@@ -885,7 +891,7 @@ function redirect(?string $route = null): RedirectResponse
885891
*/
886892
function _solidus(): string
887893
{
888-
if (config('DocTypes')->html5 ?? false) {
894+
if (config(DocTypes::class)->html5 ?? false) {
889895
return '';
890896
}
891897

@@ -973,8 +979,6 @@ function route_to(string $method, ...$params)
973979
* session()->set('foo', 'bar');
974980
* $foo = session('bar');
975981
*
976-
* @param string $val
977-
*
978982
* @return array|bool|float|int|object|Session|string|null
979983
* @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null)
980984
*/
@@ -1064,7 +1068,7 @@ function single_service(string $name, ...$params)
10641068
*/
10651069
function slash_item(string $item): ?string
10661070
{
1067-
$config = config('App');
1071+
$config = config(App::class);
10681072

10691073
if (! property_exists($config, $item)) {
10701074
return null;
@@ -1166,10 +1170,8 @@ function timer(?string $name = null, ?callable $callable = null)
11661170
*/
11671171
function view(string $name, array $data = [], array $options = []): string
11681172
{
1169-
/** @var CodeIgniter\View\View $renderer */
11701173
$renderer = Services::renderer();
11711174

1172-
/** @var \CodeIgniter\Config\View $config */
11731175
$config = config(View::class);
11741176
$saveData = $config->saveData;
11751177

0 commit comments

Comments
 (0)