• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 28448971449

30 Jun 2026 01:43PM UTC coverage: 89.169% (+0.001%) from 89.168%
28448971449

Pull #10355

github

web-flow
Merge f34cb7a0e into 7b7742fd8
Pull Request #10355: refactor: migrate `config:check` as a modern command

15 of 16 new or added lines in 1 file covered. (93.75%)

25052 of 28095 relevant lines covered (89.17%)

226.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.06
/system/Commands/Utilities/ConfigCheck.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\Commands\Utilities;
15

16
use CodeIgniter\Cache\FactoriesCache;
17
use CodeIgniter\CLI\AbstractCommand;
18
use CodeIgniter\CLI\Attributes\Command;
19
use CodeIgniter\CLI\CLI;
20
use CodeIgniter\CLI\Input\Argument;
21
use CodeIgniter\Config\BaseConfig;
22
use Config\Optimize;
23
use Kint\Kint;
24

25
/**
26
 * Check the Config values.
27
 */
28
#[Command(name: 'config:check', description: 'Check your config values.', group: 'CodeIgniter')]
29
class ConfigCheck extends AbstractCommand
30
{
31
    protected function configure(): void
32
    {
33
        $this->addArgument(new Argument(
3✔
34
            name: 'class_name',
3✔
35
            description: 'The config class to check. Short name or FQCN.',
3✔
36
            required: true,
3✔
37
        ));
3✔
38
    }
39

40
    protected function execute(array $arguments, array $options): int
41
    {
42
        /** @var class-string<BaseConfig> $class */
43
        $class = $arguments['class_name'];
3✔
44

45
        $configCacheEnabled = class_exists(Optimize::class) && (new Optimize())->configCacheEnabled;
3✔
46

47
        if ($configCacheEnabled) {
3✔
NEW
48
            (new FactoriesCache())->load('config');
×
49
        }
50

51
        $config = config($class);
3✔
52

53
        if ($config === null) {
3✔
54
            CLI::error(sprintf('Config class "%s" not found.', $class));
1✔
55

56
            return EXIT_ERROR;
1✔
57
        }
58

59
        CLI::write($this->getDump($config));
2✔
60

61
        CLI::newLine();
2✔
62
        $state = CLI::color($configCacheEnabled ? 'enabled' : 'disabled', 'green');
2✔
63
        CLI::write(sprintf('Config caching: %s', $state));
2✔
64

65
        return EXIT_SUCCESS;
2✔
66
    }
67

68
    /**
69
     * Renders the config object using Kint when available, otherwise var_dump().
70
     */
71
    private function getDump(object $config): string
72
    {
73
        if (defined('KINT_DIR') && Kint::$enabled_mode !== false) {
2✔
74
            return $this->getKintD($config);
1✔
75
        }
76

77
        return CLI::color($this->getVarDump($config), 'cyan');
1✔
78
    }
79

80
    /**
81
     * Gets object dump by Kint d()
82
     */
83
    private function getKintD(object $config): string
84
    {
85
        ob_start();
1✔
86
        d($config);
1✔
87
        $output = ob_get_clean();
1✔
88

89
        $lines = array_slice(explode("\n", trim($output)), 3, -3);
1✔
90

91
        return implode("\n", $lines);
1✔
92
    }
93

94
    /**
95
     * Gets object dump by var_dump()
96
     */
97
    private function getVarDump(object $config): string
98
    {
99
        ob_start();
1✔
100
        var_dump($config);
1✔
101
        $output = ob_get_clean();
1✔
102

103
        return preg_replace(
1✔
104
            '!.*system/Commands/Utilities/ConfigCheck.php.*\n!u',
1✔
105
            '',
1✔
106
            $output,
1✔
107
        );
1✔
108
    }
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc