diff --git a/composer.json b/composer.json index e6edd89efb65..b8f61a462bf1 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "psr/log": "^3.0" }, "require-dev": { - "boundwize/structarmed": "^0.16", + "boundwize/structarmed": "^0.17", "codeigniter/phpstan-codeigniter": "^2.1", "fakerphp/faker": "^1.24", "kint-php/kint": "^6.1", diff --git a/structarmed.php b/structarmed.php index e1027f578ce2..fc5c799b13c3 100644 --- a/structarmed.php +++ b/structarmed.php @@ -11,6 +11,7 @@ * the LICENSE file that was distributed with this source code. */ +use Boundwize\StructArmed\Preset\Presets\CodeQualityPreset; use CodeIgniter\Cache\ResponseCache; use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\HTTP\Header; @@ -45,9 +46,12 @@ __DIR__ . '/tests/system/Config/fixtures', ], __DIR__ . '/system/ThirdParty', + CodeQualityPreset::ANONYMOUS_FUNCTIONS_MUST_BE_STATIC => [ + __DIR__ . '/system/View/Cells/Cell.php', + ], ]) ->cacheDirectory(is_dir('/tmp') ? '/tmp/structarmed' : null) - ->withPreset(Preset::PSR4()) + ->withPresets(Preset::PSR4(), Preset::CODEQUALITY()) // Resolve CodeIgniter layers from class names because several layers share directories. ->layerPattern('API', '/^CodeIgniter\\\\API\\\\.*$/') ->layerPattern('Cache', '/^CodeIgniter\\\\Cache\\\\.*$/') diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 4666149f27e9..92ff2026bb19 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -531,7 +531,7 @@ private function autoloadKint(): void { // If we have KINT_DIR it means it's already loaded via composer if (! defined('KINT_DIR')) { - spl_autoload_register(function ($class): void { + spl_autoload_register(static function ($class): void { $class = explode('\\', $class); if (array_shift($class) !== 'Kint') { diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 177edbd8d753..1654e82399e7 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -261,7 +261,7 @@ private function autoloadKint(): void { // If we have KINT_DIR it means it's already loaded via composer if (! defined('KINT_DIR')) { - spl_autoload_register(function ($class): void { + spl_autoload_register(static function ($class): void { $class = explode('\\', $class); if (array_shift($class) !== 'Kint') { diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 82ff14253d17..be8f64f31775 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -507,7 +507,7 @@ public function testCastDateTimeWithTimestampTimezone(): void $entity = $this->getCastEntity(); - $entity->eighth = 1722988800; // 2024-08-07 00:00:00 UTC + $entity->eighth = 1_722_988_800; // 2024-08-07 00:00:00 UTC $this->assertInstanceOf(Time::class, $entity->eighth); // The timezone is the default timezone, not UTC. diff --git a/tests/system/I18n/TimeTest.php b/tests/system/I18n/TimeTest.php index 0d08af39f3f2..ef6712f37259 100644 --- a/tests/system/I18n/TimeTest.php +++ b/tests/system/I18n/TimeTest.php @@ -290,7 +290,7 @@ public function testCreateFromTimestamp(): void public function testCreateFromTimestampWithMicroseconds(): void { - $timestamp = 1489762800.654321; + $timestamp = 1_489_762_800.654321; $locale = setlocale(LC_NUMERIC, '0'); setlocale(LC_NUMERIC, 'de_DE.UTF-8', 'de_DE'); diff --git a/tests/system/SuperglobalsTest.php b/tests/system/SuperglobalsTest.php index de1fed832f3a..e4b8b23b2b28 100644 --- a/tests/system/SuperglobalsTest.php +++ b/tests/system/SuperglobalsTest.php @@ -57,16 +57,16 @@ public function testServerSetWithArray(): void public function testServerSetWithInt(): void { - $this->superglobals->setServer('REQUEST_TIME', 1234567890); + $this->superglobals->setServer('REQUEST_TIME', 1_234_567_890); - $this->assertSame(1234567890, $this->superglobals->server('REQUEST_TIME')); + $this->assertSame(1_234_567_890, $this->superglobals->server('REQUEST_TIME')); } public function testServerSetWithFloat(): void { - $this->superglobals->setServer('REQUEST_TIME_FLOAT', 1234567890.123); + $this->superglobals->setServer('REQUEST_TIME_FLOAT', 1_234_567_890.123); - $this->assertEqualsWithDelta(1234567890.123, $this->superglobals->server('REQUEST_TIME_FLOAT'), PHP_FLOAT_EPSILON); + $this->assertEqualsWithDelta(1_234_567_890.123, $this->superglobals->server('REQUEST_TIME_FLOAT'), PHP_FLOAT_EPSILON); } public function testServerUnset(): void