Skip to content

Commit 6b9d888

Browse files
committed
feat(app): Replace Kint with internal tool. WIP
1 parent 858d040 commit 6b9d888

182 files changed

Lines changed: 6913 additions & 15192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

admin/framework/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"codeigniter/coding-standard": "^1.7",
2121
"fakerphp/faker": "^1.24",
2222
"friendsofphp/php-cs-fixer": "^3.47.1",
23-
"kint-php/kint": "^6.0",
2423
"mikey179/vfsstream": "^1.6.12",
2524
"nexusphp/cs-config": "^3.6",
2625
"phpunit/phpunit": "^10.5.16 || ^11.2",

app/Config/Boot/development.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
| DEBUG MODE
2929
|--------------------------------------------------------------------------
3030
| Debug mode is an experimental flag that can allow changes throughout
31-
| the system. This will control whether Kint is loaded, and a few other
31+
| the system. This will control whether the Debug Dumper is loaded, and a few other
3232
| items. It can always be used within your own application too.
3333
*/
3434
defined('CI_DEBUG') || define('CI_DEBUG', true);

app/Config/Kint.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"require-dev": {
2020
"codeigniter/phpstan-codeigniter": "1.x-dev",
2121
"fakerphp/faker": "^1.24",
22-
"kint-php/kint": "^6.0",
2322
"mikey179/vfsstream": "^1.6.12",
2423
"nexusphp/tachycardia": "^2.0",
2524
"phpstan/extension-installer": "^1.4",

rector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
__DIR__ . '/system/Database/SQLite3/Utils.php',
158158
__DIR__ . '/system/HTTP/DownloadResponse.php',
159159
__DIR__ . '/system/HTTP/SiteURI.php',
160-
__DIR__ . '/system/Helpers/kint_helper.php',
161160
__DIR__ . '/tests/_support/Autoloader/FatalLocator.php',
162161
],
163162

system/Autoloader/Autoloader.php

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
use Composer\Autoload\ClassLoader;
2020
use Composer\InstalledVersions;
2121
use Config\Autoload;
22-
use Config\Kint as KintConfig;
2322
use Config\Modules;
24-
use Kint\Kint;
25-
use Kint\Renderer\CliRenderer;
26-
use Kint\Renderer\RichRenderer;
2723

2824
/**
2925
* An autoloader that uses both PSR4 autoloading, and traditional classmaps.
@@ -487,76 +483,4 @@ public function loadHelpers(): void
487483
{
488484
helper($this->helpers);
489485
}
490-
491-
/**
492-
* Initializes Kint
493-
*/
494-
public function initializeKint(bool $debug = false): void
495-
{
496-
if ($debug) {
497-
$this->autoloadKint();
498-
$this->configureKint();
499-
} elseif (class_exists(Kint::class)) {
500-
// In case that Kint is already loaded via Composer.
501-
Kint::$enabled_mode = false;
502-
}
503-
504-
helper('kint');
505-
}
506-
507-
private function autoloadKint(): void
508-
{
509-
// If we have KINT_DIR it means it's already loaded via composer
510-
if (! defined('KINT_DIR')) {
511-
spl_autoload_register(function ($class): void {
512-
$class = explode('\\', $class);
513-
514-
if (array_shift($class) !== 'Kint') {
515-
return;
516-
}
517-
518-
$file = SYSTEMPATH . 'ThirdParty/Kint/' . implode('/', $class) . '.php';
519-
520-
if (is_file($file)) {
521-
require_once $file;
522-
}
523-
});
524-
525-
require_once SYSTEMPATH . 'ThirdParty/Kint/init.php';
526-
}
527-
}
528-
529-
private function configureKint(): void
530-
{
531-
$config = new KintConfig();
532-
533-
Kint::$depth_limit = $config->maxDepth;
534-
Kint::$display_called_from = $config->displayCalledFrom;
535-
Kint::$expanded = $config->expanded;
536-
537-
if (isset($config->plugins) && is_array($config->plugins)) {
538-
Kint::$plugins = $config->plugins;
539-
}
540-
541-
$csp = service('csp');
542-
if ($csp->enabled()) {
543-
RichRenderer::$js_nonce = $csp->getScriptNonce();
544-
RichRenderer::$css_nonce = $csp->getStyleNonce();
545-
}
546-
547-
RichRenderer::$theme = $config->richTheme;
548-
RichRenderer::$folder = $config->richFolder;
549-
550-
if (isset($config->richObjectPlugins) && is_array($config->richObjectPlugins)) {
551-
RichRenderer::$value_plugins = $config->richObjectPlugins;
552-
}
553-
if (isset($config->richTabPlugins) && is_array($config->richTabPlugins)) {
554-
RichRenderer::$tab_plugins = $config->richTabPlugins;
555-
}
556-
557-
CliRenderer::$cli_colors = $config->cliColors;
558-
CliRenderer::$force_utf8 = $config->cliForceUTF8;
559-
CliRenderer::$detect_width = $config->cliDetectWidth;
560-
CliRenderer::$min_terminal_width = $config->cliMinWidth;
561-
}
562486
}

system/Boot.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function bootWeb(Paths $paths): int
5454
static::loadCommonFunctions();
5555
static::loadAutoloader();
5656
static::setExceptionHandler();
57-
static::initializeKint();
57+
static::initializeDebug();
5858

5959
$configCacheEnabled = class_exists(Optimize::class)
6060
&& (new Optimize())->configCacheEnabled;
@@ -96,7 +96,7 @@ public static function bootConsole(Paths $paths): void
9696
static::loadCommonFunctions();
9797
static::loadAutoloader();
9898
static::setExceptionHandler();
99-
static::initializeKint();
99+
static::initializeDebug();
100100
static::autoloadHelpers();
101101

102102
// We need to force the request to be a CLIRequest since we're in console
@@ -124,7 +124,7 @@ public static function bootSpark(Paths $paths): int
124124
static::loadCommonFunctions();
125125
static::loadAutoloader();
126126
static::setExceptionHandler();
127-
static::initializeKint();
127+
static::initializeDebug();
128128
static::autoloadHelpers();
129129

130130
static::initializeCodeIgniter();
@@ -147,7 +147,7 @@ public static function bootTest(Paths $paths): void
147147
static::loadCommonFunctions();
148148
static::loadAutoloader();
149149
static::setExceptionHandler();
150-
static::initializeKint();
150+
static::initializeDebug();
151151
static::autoloadHelpers();
152152
}
153153

@@ -326,9 +326,17 @@ protected static function checkMissingExtensions(): void
326326
exit(EXIT_ERROR);
327327
}
328328

329-
protected static function initializeKint(): void
329+
protected static function initializeDebug(): void
330330
{
331-
service('autoloader')->initializeKint(CI_DEBUG);
331+
// Always load the debug helper unless in a protected environment
332+
$debugConfig = config('Debug');
333+
$isProtected = in_array(ENVIRONMENT, $debugConfig->forbiddenEnvironments, true);
334+
335+
if ($isProtected) {
336+
return;
337+
}
338+
339+
helper('debug');
332340
}
333341

334342
protected static function loadConfigCache(): FactoriesCache

system/CodeIgniter.php

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@
3434
use Config\App;
3535
use Config\Cache;
3636
use Config\Feature;
37-
use Config\Kint as KintConfig;
3837
use Config\Services;
3938
use Exception;
40-
use Kint;
41-
use Kint\Renderer\CliRenderer;
42-
use Kint\Renderer\RichRenderer;
4339
use Locale;
4440
use Throwable;
4541

@@ -192,89 +188,6 @@ public function initialize()
192188
date_default_timezone_set($this->config->appTimezone ?? 'UTC');
193189
}
194190

195-
/**
196-
* Initializes Kint
197-
*
198-
* @return void
199-
*
200-
* @deprecated 4.5.0 Moved to Autoloader.
201-
*/
202-
protected function initializeKint()
203-
{
204-
if (CI_DEBUG) {
205-
$this->autoloadKint();
206-
$this->configureKint();
207-
} elseif (class_exists(Kint::class)) {
208-
// In case that Kint is already loaded via Composer.
209-
Kint::$enabled_mode = false;
210-
// @codeCoverageIgnore
211-
}
212-
213-
helper('kint');
214-
}
215-
216-
/**
217-
* @deprecated 4.5.0 Moved to Autoloader.
218-
*/
219-
private function autoloadKint(): void
220-
{
221-
// If we have KINT_DIR it means it's already loaded via composer
222-
if (! defined('KINT_DIR')) {
223-
spl_autoload_register(function ($class): void {
224-
$class = explode('\\', $class);
225-
226-
if (array_shift($class) !== 'Kint') {
227-
return;
228-
}
229-
230-
$file = SYSTEMPATH . 'ThirdParty/Kint/' . implode('/', $class) . '.php';
231-
232-
if (is_file($file)) {
233-
require_once $file;
234-
}
235-
});
236-
237-
require_once SYSTEMPATH . 'ThirdParty/Kint/init.php';
238-
}
239-
}
240-
241-
/**
242-
* @deprecated 4.5.0 Moved to Autoloader.
243-
*/
244-
private function configureKint(): void
245-
{
246-
$config = new KintConfig();
247-
248-
Kint::$depth_limit = $config->maxDepth;
249-
Kint::$display_called_from = $config->displayCalledFrom;
250-
Kint::$expanded = $config->expanded;
251-
252-
if (isset($config->plugins) && is_array($config->plugins)) {
253-
Kint::$plugins = $config->plugins;
254-
}
255-
256-
$csp = Services::csp();
257-
if ($csp->enabled()) {
258-
RichRenderer::$js_nonce = $csp->getScriptNonce();
259-
RichRenderer::$css_nonce = $csp->getStyleNonce();
260-
}
261-
262-
RichRenderer::$theme = $config->richTheme;
263-
RichRenderer::$folder = $config->richFolder;
264-
265-
if (isset($config->richObjectPlugins) && is_array($config->richObjectPlugins)) {
266-
RichRenderer::$value_plugins = $config->richObjectPlugins;
267-
}
268-
if (isset($config->richTabPlugins) && is_array($config->richTabPlugins)) {
269-
RichRenderer::$tab_plugins = $config->richTabPlugins;
270-
}
271-
272-
CliRenderer::$cli_colors = $config->cliColors;
273-
CliRenderer::$force_utf8 = $config->cliForceUTF8;
274-
CliRenderer::$detect_width = $config->cliDetectWidth;
275-
CliRenderer::$min_terminal_width = $config->cliMinWidth;
276-
}
277-
278191
/**
279192
* Launch the application!
280193
*

system/ComposerScripts.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ final class ComposerScripts
4242
* @var array<string, array<string, string>>
4343
*/
4444
private static array $dependencies = [
45-
'kint-src' => [
46-
'license' => __DIR__ . '/../vendor/kint-php/kint/LICENSE',
47-
'from' => __DIR__ . '/../vendor/kint-php/kint/src/',
48-
'to' => __DIR__ . '/ThirdParty/Kint/',
49-
],
50-
'kint-resources' => [
51-
'from' => __DIR__ . '/../vendor/kint-php/kint/resources/',
52-
'to' => __DIR__ . '/ThirdParty/Kint/resources/',
53-
],
5445
'escaper' => [
5546
'license' => __DIR__ . '/../vendor/laminas/laminas-escaper/LICENSE.md',
5647
'from' => __DIR__ . '/../vendor/laminas/laminas-escaper/src/',
@@ -72,20 +63,13 @@ public static function postUpdate(): void
7263
self::recursiveDelete(self::$path);
7364

7465
foreach (self::$dependencies as $key => $dependency) {
75-
// Kint may be removed.
76-
if (! is_dir($dependency['from']) && str_starts_with($key, 'kint')) {
77-
continue;
78-
}
79-
8066
self::recursiveMirror($dependency['from'], $dependency['to']);
8167

8268
if (isset($dependency['license'])) {
8369
$license = basename($dependency['license']);
8470
copy($dependency['license'], $dependency['to'] . '/' . $license);
8571
}
8672
}
87-
88-
self::copyKintInitFiles();
8973
}
9074

9175
/**
@@ -158,17 +142,4 @@ private static function recursiveMirror(string $originDir, string $targetDir): v
158142
}
159143
}
160144
}
161-
162-
/**
163-
* Copy Kint's init files into `system/ThirdParty/Kint/`
164-
*/
165-
private static function copyKintInitFiles(): void
166-
{
167-
$originDir = self::$dependencies['kint-src']['from'] . '../';
168-
$targetDir = self::$dependencies['kint-src']['to'];
169-
170-
foreach (['init.php', 'init_helpers.php'] as $kintInit) {
171-
@copy($originDir . $kintInit, $targetDir . $kintInit);
172-
}
173-
}
174145
}

0 commit comments

Comments
 (0)