Skip to content

Commit ab9bf33

Browse files
committed
Release v4.7.3
1 parent b3359be commit ab9bf33

84 files changed

Lines changed: 396 additions & 342 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.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ _modules/*
123123
.vscode/
124124

125125
/results/
126-
/phpunit*.xml
126+
/phpunit.xml

app/Config/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class Database extends Config
140140
// * @var array<string, mixed>
141141
// */
142142
// public array $default = [
143-
// 'DSN' => 'localhost:1521/XEPDB1',
143+
// 'DSN' => 'localhost:1521/FREEPDB1',
144144
// 'username' => 'root',
145145
// 'password' => 'root',
146146
// 'DBDriver' => 'OCI8',

app/Config/Events.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525

2626
Events::on('pre_system', static function (): void {
2727
if (ENVIRONMENT !== 'testing') {
28-
if (ini_get('zlib.output_compression')) {
28+
$value = ini_get('zlib.output_compression');
29+
30+
if (filter_var($value, FILTER_VALIDATE_BOOLEAN) || (int) $value > 0) {
2931
throw FrameworkException::forEnabledZlibOutputCompression();
3032
}
3133

app/Config/Routes.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22

33
use CodeIgniter\Router\RouteCollection;
44

5-
/**
6-
* @var RouteCollection $routes
7-
*/
5+
/** @var RouteCollection $routes */
86
$routes->get('/', 'Home::index');

app/Config/View.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
use CodeIgniter\Config\View as BaseView;
66
use CodeIgniter\View\ViewDecoratorInterface;
77

8-
/**
9-
* @phpstan-type parser_callable (callable(mixed): mixed)
10-
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
11-
*/
128
class View extends BaseView
139
{
1410
/**
@@ -34,8 +30,7 @@ class View extends BaseView
3430
* { title|esc(js) }
3531
* { created_on|date(Y-m-d)|esc(attr) }
3632
*
37-
* @var array<string, string>
38-
* @phpstan-var array<string, parser_callable_string>
33+
* @var array<string, (callable(mixed): mixed)&string>
3934
*/
4035
public $filters = [];
4136

@@ -44,8 +39,7 @@ class View extends BaseView
4439
* by the core Parser by creating aliases that will be replaced with
4540
* any callable. Can be single or tag pair.
4641
*
47-
* @var array<string, callable|list<string>|string>
48-
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
42+
* @var array<string, (callable(mixed...): mixed)|((callable(mixed...): mixed)&string)|list<(callable(mixed...): mixed)&string>>
4943
*/
5044
public $plugins = [];
5145

phpunit.xml.dist renamed to phpunit.dist.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
55
bootstrap="system/Test/bootstrap.php"
66
backupGlobals="false"
77
beStrictAboutOutputDuringTests="true"
88
colors="true"
99
columns="max"
1010
failOnRisky="true"
1111
failOnWarning="true"
12-
cacheDirectory="build/.phpunit.cache">
13-
<coverage
14-
includeUncoveredFiles="true"
15-
pathCoverage="false"
16-
ignoreDeprecatedCodeUnits="true"
17-
disableCodeCoverageIgnore="true">
12+
cacheDirectory="build/.phpunit.cache"
13+
>
14+
<coverage pathCoverage="false" ignoreDeprecatedCodeUnits="true">
1815
<report>
1916
<clover outputFile="build/logs/clover.xml"/>
2017
<html outputDirectory="build/logs/html"/>
2118
<php outputFile="build/logs/coverage.serialized"/>
2219
<text outputFile="php://stdout" showUncoveredFiles="false"/>
2320
</report>
2421
</coverage>
22+
2523
<testsuites>
2624
<testsuite name="App">
2725
<directory>./tests</directory>
2826
</testsuite>
2927
</testsuites>
28+
3029
<logging>
3130
<testdoxHtml outputFile="build/logs/testdox.html"/>
3231
<testdoxText outputFile="build/logs/testdox.txt"/>
3332
<junit outputFile="build/logs/logfile.xml"/>
3433
</logging>
34+
3535
<source>
3636
<include>
3737
<directory suffix=".php">./app</directory>
@@ -41,6 +41,7 @@
4141
<file>./app/Config/Routes.php</file>
4242
</exclude>
4343
</source>
44+
4445
<php>
4546
<server name="app.baseURL" value="http://example.com/"/>
4647
<server name="CODEIGNITER_SCREAM_DEPRECATIONS" value="0"/>

system/Autoloader/Autoloader.php

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace CodeIgniter\Autoloader;
1515

16+
use Closure;
1617
use CodeIgniter\Exceptions\ConfigException;
1718
use CodeIgniter\Exceptions\InvalidArgumentException;
1819
use CodeIgniter\Exceptions\RuntimeException;
@@ -93,6 +94,18 @@ class Autoloader
9394
*/
9495
protected $helpers = ['url'];
9596

97+
/**
98+
* Stores the closures registered with spl_autoload_register()
99+
* so that unregister() can remove the exact same instances.
100+
*
101+
* @var list<Closure(string): void>
102+
*/
103+
private array $registeredClosures = [];
104+
105+
public function __construct(private readonly string $composerPath = COMPOSER_PATH)
106+
{
107+
}
108+
96109
/**
97110
* Reads in the configuration array (described above) and stores
98111
* the valid parts that we'll need.
@@ -127,7 +140,7 @@ public function initialize(Autoload $config, Modules $modules)
127140
$this->helpers = [...$this->helpers, ...$config->helpers];
128141
}
129142

130-
if (is_file(COMPOSER_PATH)) {
143+
if (is_file($this->composerPath)) {
131144
$this->loadComposerAutoloader($modules);
132145
}
133146

@@ -139,11 +152,11 @@ private function loadComposerAutoloader(Modules $modules): void
139152
// The path to the vendor directory.
140153
// We do not want to enforce this, so set the constant if Composer was used.
141154
if (! defined('VENDORPATH')) {
142-
define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR);
155+
define('VENDORPATH', dirname($this->composerPath) . DIRECTORY_SEPARATOR);
143156
}
144157

145158
/** @var ClassLoader $composer */
146-
$composer = include COMPOSER_PATH;
159+
$composer = include $this->composerPath;
147160

148161
// Should we load through Composer's namespaces, also?
149162
if ($modules->discoverInComposer) {
@@ -166,8 +179,17 @@ private function loadComposerAutoloader(Modules $modules): void
166179
*/
167180
public function register()
168181
{
169-
spl_autoload_register($this->loadClassmap(...), true);
170-
spl_autoload_register($this->loadClass(...), true);
182+
// Store the exact Closure instances so unregister() can remove them.
183+
// First-class callable syntax (e.g. $this->loadClass(...)) creates a
184+
// new Closure object on every call, so we must reuse the same instances.
185+
$loadClassmap = $this->loadClassmap(...);
186+
$loadClass = $this->loadClass(...);
187+
188+
$this->registeredClosures[] = $loadClassmap;
189+
$this->registeredClosures[] = $loadClass;
190+
191+
spl_autoload_register($loadClassmap, true);
192+
spl_autoload_register($loadClass, true);
171193

172194
foreach ($this->files as $file) {
173195
$this->includeFile($file);
@@ -179,8 +201,11 @@ public function register()
179201
*/
180202
public function unregister(): void
181203
{
182-
spl_autoload_unregister($this->loadClass(...));
183-
spl_autoload_unregister($this->loadClassmap(...));
204+
foreach ($this->registeredClosures as $closure) {
205+
spl_autoload_unregister($closure);
206+
}
207+
208+
$this->registeredClosures = [];
184209
}
185210

186211
/**
@@ -451,14 +476,12 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa
451476
*/
452477
protected function discoverComposerNamespaces()
453478
{
454-
if (! is_file(COMPOSER_PATH)) {
479+
if (! is_file($this->composerPath)) {
455480
return;
456481
}
457482

458-
/**
459-
* @var ClassLoader $composer
460-
*/
461-
$composer = include COMPOSER_PATH;
483+
/** @var ClassLoader $composer */
484+
$composer = include $this->composerPath;
462485
$paths = $composer->getPrefixesPsr4();
463486
$classes = $composer->getClassMap();
464487

system/Autoloader/FileLocator.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,7 @@ public function listFiles(string $path): array
330330
helper('filesystem');
331331

332332
foreach ($this->getNamespaces() as $namespace) {
333-
$fullPath = $namespace['path'] . $path;
334-
$resolvedPath = realpath($fullPath);
335-
$fullPath = $resolvedPath !== false ? $resolvedPath : $fullPath;
336-
337-
if (! is_dir($fullPath)) {
338-
continue;
339-
}
340-
341-
$tempFiles = get_filenames($fullPath, true, false, false);
342-
343-
if ($tempFiles !== []) {
344-
$files = array_merge($files, $tempFiles);
345-
}
333+
$files = array_merge($files, get_filenames($namespace['path'] . $path, true, false, false));
346334
}
347335

348336
return $files;

system/BaseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ public function findColumn(string $columnName)
653653
*/
654654
public function findAll(?int $limit = null, int $offset = 0)
655655
{
656-
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
656+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; // @phpstan-ignore nullCoalesce.property
657657
if ($limitZeroAsAll) {
658658
$limit ??= 0;
659659
}

system/Boot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public static function preload(Paths $paths): void
205205
protected static function loadDotEnv(Paths $paths): void
206206
{
207207
require_once $paths->systemDirectory . '/Config/DotEnv.php';
208-
$envDirectory = $paths->envDirectory ?? $paths->appDirectory . '/../';
208+
$envDirectory = $paths->envDirectory ?? $paths->appDirectory . '/../'; // @phpstan-ignore nullCoalesce.property
209209
(new DotEnv($envDirectory))->load();
210210
}
211211

0 commit comments

Comments
 (0)