diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60bee3d5..2387d25c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,6 @@ name: CI on: push: branches: - - master - 5.x pull_request: branches: diff --git a/.phive/phars.xml b/.phive/phars.xml index 63c4fa23..2e1dc81e 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,4 @@ - - + diff --git a/composer.json b/composer.json index fc1eeb69..3c383418 100644 --- a/composer.json +++ b/composer.json @@ -48,16 +48,15 @@ "scripts": { "check": [ "@cs-check", - "@test", - "@stan" + "@stan", + "@test" ], "cs-check": "phpcs -p src/ tests/TestCase/", "cs-fix": "phpcbf src/ tests/TestCase/", "test": "phpunit --stderr", "stan": "phpstan analyse src/ && psalm --show-info=false", "stan-test": "phpstan analyse tests/", - "psalm": "psalm", - "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~1.8 vimeo/psalm:~4.23 && mv composer.backup composer.json", + "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~2.0 && mv composer.backup composer.json", "coverage-test": "phpunit --stderr --coverage-clover=clover.xml" }, "prefer-stable": true, diff --git a/phpstan.neon b/phpstan.neon index 18f7ad40..bc47cfd6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,9 +2,10 @@ includes: - phpstan-baseline.neon parameters: - level: 6 - checkMissingIterableValueType: false + level: 7 bootstrapFiles: - tests/bootstrap.php paths: - src/ + ignoreErrors: + - identifier: missingType.iterableValue diff --git a/src/Command/BuildCommand.php b/src/Command/BuildCommand.php index 6e0658ce..864047f6 100644 --- a/src/Command/BuildCommand.php +++ b/src/Command/BuildCommand.php @@ -58,8 +58,8 @@ public function execute(Arguments $args, ConsoleIo $io): int { $configFinder = new ConfigFinder(); $config = $configFinder->loadAll( - $args->getOption('config'), - (bool)$args->getOption('skip-plugins') + (string)$args->getOption('config'), + (bool)$args->getOption('skip-plugins'), ); $factory = new Factory($config); diff --git a/src/Command/ClearCommand.php b/src/Command/ClearCommand.php index 2800ebc9..450d40fe 100644 --- a/src/Command/ClearCommand.php +++ b/src/Command/ClearCommand.php @@ -48,7 +48,7 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar public function execute(Arguments $args, ConsoleIo $io): int { $configFinder = new ConfigFinder(); - $config = $configFinder->loadAll($args->getOption('config')); + $config = $configFinder->loadAll((string)$args->getOption('config')); $factory = new Factory($config); $io->verbose('Clearing build timestamp.'); diff --git a/src/Filter/ImportInline.php b/src/Filter/ImportInline.php index ada6a914..465418cc 100644 --- a/src/Filter/ImportInline.php +++ b/src/Filter/ImportInline.php @@ -25,7 +25,7 @@ protected function scanner(): AssetScanner } $this->scanner = new AssetScanner( $this->_settings['paths'], - $this->_settings['theme'] ?? null + $this->_settings['theme'] ?? null, ); return $this->scanner; diff --git a/src/Filter/Sprockets.php b/src/Filter/Sprockets.php index d6f9d9c4..bc1b8a90 100644 --- a/src/Filter/Sprockets.php +++ b/src/Filter/Sprockets.php @@ -25,7 +25,7 @@ protected function _scanner(): AssetScanner } $this->_scanner = new AssetScanner( $this->_settings['paths'], - $this->_settings['theme'] ?? null + $this->_settings['theme'] ?? null, ); return $this->_scanner; diff --git a/src/Middleware/AssetCompressMiddleware.php b/src/Middleware/AssetCompressMiddleware.php index 33325d35..a73dd60b 100644 --- a/src/Middleware/AssetCompressMiddleware.php +++ b/src/Middleware/AssetCompressMiddleware.php @@ -60,7 +60,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface // Make sure the request looks like an asset. $targetName = $this->getName($config, $request->getUri()->getPath()); - if (!$targetName) { + if (!is_string($targetName)) { return $handler->handle($request); } diff --git a/src/View/Helper/AssetCompressHelper.php b/src/View/Helper/AssetCompressHelper.php index 9b8886bd..919948c0 100644 --- a/src/View/Helper/AssetCompressHelper.php +++ b/src/View/Helper/AssetCompressHelper.php @@ -175,7 +175,7 @@ public function css(string $file, array $options = []): ?string $file = $this->_addExt($file, '.css'); if (!$this->collection()->contains($file)) { throw new RuntimeException( - "Cannot create a stylesheet tag for a '$file'. That build is not defined." + "Cannot create a stylesheet tag for a '$file'. That build is not defined.", ); } $output = ''; @@ -218,7 +218,7 @@ public function script(string $file, array $options = []): ?string $file = $this->_addExt($file, '.js'); if (!$this->collection()->contains($file)) { throw new RuntimeException( - "Cannot create a script tag for a '$file'. That build is not defined." + "Cannot create a script tag for a '$file'. That build is not defined.", ); } $output = ''; @@ -250,7 +250,9 @@ protected function _relativizePath(string $path): string { $plugins = Plugin::loaded(); $index = array_search('AssetCompress', $plugins); - unset($plugins[$index]); + if ($index !== false) { + unset($plugins[$index]); + } foreach ($plugins as $plugin) { $pluginPath = Plugin::path($plugin) . 'webroot'; diff --git a/tests/TestCase/Command/AssetCompressCommandsTest.php b/tests/TestCase/Command/AssetCompressCommandsTest.php index 6a5a1475..47a1b0e2 100644 --- a/tests/TestCase/Command/AssetCompressCommandsTest.php +++ b/tests/TestCase/Command/AssetCompressCommandsTest.php @@ -26,8 +26,6 @@ public function setUp(): void mkdir(WWW_ROOT . 'cache_js'); mkdir(WWW_ROOT . 'cache_css'); mkdir(WWW_ROOT . 'cache_svg'); - - $this->loadPlugins(['AssetCompress']); } /** diff --git a/tests/TestCase/FactoryTest.php b/tests/TestCase/FactoryTest.php index 6102b9d2..34e21ccd 100644 --- a/tests/TestCase/FactoryTest.php +++ b/tests/TestCase/FactoryTest.php @@ -11,6 +11,13 @@ class FactoryTest extends TestCase { + protected $config; + protected $integrationFile; + protected $themedFile; + protected $pluginFile; + protected $overrideFile; + protected $timestampFile; + public function setUp(): void { parent::setUp(); @@ -85,7 +92,7 @@ public function testAssetCollection() $this->assertEquals( str_replace(DS, '/', WWW_ROOT . 'cache_js/libs.js'), str_replace(DS, '/', $asset->path()), - 'Asset path is wrong' + 'Asset path is wrong', ); } @@ -112,7 +119,7 @@ public function testAssetCollectionThemed() $this->assertCount(1, $files); $this->assertEquals( str_replace(DS, '/', APP . 'Plugin/Red/webroot/theme.css'), - str_replace(DS, '/', $files[0]->path()) + str_replace(DS, '/', $files[0]->path()), ); } @@ -138,7 +145,7 @@ public function testAssetCollectionPlugins() $this->assertCount(1, $asset->files()); $this->assertEquals( str_replace('/', DS, APP . 'Plugin/TestAsset/webroot/plugin.js'), - $asset->files()[0]->path() + $asset->files()[0]->path(), ); $asset = $collection->get('plugins.css'); @@ -146,7 +153,7 @@ public function testAssetCollectionPlugins() $this->assertCount(2, $files); $this->assertEquals( APP . 'css' . DS . 'nav.css', - $asset->files()[0]->path() + $asset->files()[0]->path(), ); } @@ -163,15 +170,15 @@ public function testAssetCreationWithAdditionalPath() $this->assertCount(3, $files); $this->assertEquals( APP . 'js' . DS . 'base.js', - $files[0]->path() + $files[0]->path(), ); $this->assertEquals( APP . 'js' . DS . 'library_file.js', - $files[1]->path() + $files[1]->path(), ); $this->assertEquals( APP . 'js' . DS . 'classes' . DS . 'base_class.js', - $files[2]->path() + $files[2]->path(), ); } diff --git a/tests/TestCase/Middleware/AssetCompressMiddlewareTest.php b/tests/TestCase/Middleware/AssetCompressMiddlewareTest.php index b2cba9d7..12884012 100644 --- a/tests/TestCase/Middleware/AssetCompressMiddlewareTest.php +++ b/tests/TestCase/Middleware/AssetCompressMiddlewareTest.php @@ -14,6 +14,12 @@ class AssetCompressMiddlewareTest extends TestCase { protected $nextInvoked = false; + protected $testConfig; + protected $middleware; + protected $request; + protected $response; + protected $handler; + /** * Setup method * diff --git a/tests/TestCase/View/Helper/AssetCompressHelperTest.php b/tests/TestCase/View/Helper/AssetCompressHelperTest.php index 03bf8ef4..5e2b632b 100644 --- a/tests/TestCase/View/Helper/AssetCompressHelperTest.php +++ b/tests/TestCase/View/Helper/AssetCompressHelperTest.php @@ -14,6 +14,10 @@ class AssetCompressHelperTest extends TestCase { + protected $_testFiles; + protected $View; + protected $Helper; + /** * start a test * @@ -325,13 +329,13 @@ public function testUrlFullOption() $result = $this->Helper->url('libs.js', ['full' => true]); $this->assertEquals( 'http://localhost/cache_js/libs.js', - $result + $result, ); $result = $this->Helper->url('libs.js', true); $this->assertEquals( 'http://localhost/cache_js/libs.js', - $result + $result, ); }