Skip to content

refactor: Update PHPDoc Common::config #7224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Config\Factories;
use CodeIgniter\Cookie\Cookie;
use CodeIgniter\Cookie\CookieStore;
Expand All @@ -31,6 +32,7 @@
use CodeIgniter\Test\TestLogger;
use Config\App;
use Config\Database;
use Config\DocTypes;
use Config\Logger;
use Config\Services;
use Config\View;
Expand All @@ -47,8 +49,7 @@
*/
function app_timezone(): string
{
/** @var App $config */
$config = config('App');
$config = config(App::class);

return $config->appTimezone;
}
Expand Down Expand Up @@ -203,7 +204,12 @@ function command(string $command)
/**
* More simple way of getting config instances from Factories
*
* @return object|null
* @template ConfigTemplate of BaseConfig
*
* @param class-string<ConfigTemplate>|string $name
*
* @return ConfigTemplate|null
* @phpstan-return ($name is class-string<ConfigTemplate> ? ConfigTemplate : object|null)
*/
function config(string $name, bool $getShared = true)
{
Expand Down Expand Up @@ -495,7 +501,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
Services::session(null, true)->regenerate(); // @codeCoverageIgnore
}

$baseURL = config('App')->baseURL;
$baseURL = config(App::class)->baseURL;

if (strpos($baseURL, 'https://') === 0) {
$authority = substr($baseURL, strlen('https://'));
Expand Down Expand Up @@ -885,7 +891,7 @@ function redirect(?string $route = null): RedirectResponse
*/
function _solidus(): string
{
if (config('DocTypes')->html5 ?? false) {
if (config(DocTypes::class)->html5 ?? false) {
return '';
}

Expand Down Expand Up @@ -973,8 +979,6 @@ function route_to(string $method, ...$params)
* session()->set('foo', 'bar');
* $foo = session('bar');
*
* @param string $val
*
* @return array|bool|float|int|object|Session|string|null
* @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null)
*/
Expand Down Expand Up @@ -1064,7 +1068,7 @@ function single_service(string $name, ...$params)
*/
function slash_item(string $item): ?string
{
$config = config('App');
$config = config(App::class);

if (! property_exists($config, $item)) {
return null;
Expand Down Expand Up @@ -1166,10 +1170,8 @@ function timer(?string $name = null, ?callable $callable = null)
*/
function view(string $name, array $data = [], array $options = []): string
{
/** @var CodeIgniter\View\View $renderer */
$renderer = Services::renderer();

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

Expand Down