diff --git a/.codeclimate.yml b/.codeclimate.yml index caa9009..25d8ed0 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,21 +1,21 @@ version: "2" checks: argument-count: - enabled: true + enabled: false complex-logic: - enabled: true + enabled: false file-lines: enabled: false method-complexity: - enabled: true + enabled: false method-count: - enabled: true + enabled: false method-lines: - enabled: true + enabled: false nested-control-flow: enabled: true return-statements: - enabled: true + enabled: false similar-code: enabled: false identical-code: diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3e4ae31..543c7c5 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -19,7 +19,7 @@ jobs: validate: name: "Validate Project" - uses: "mimmi20/ci/.github/workflows/validate.yml@8.1" + uses: "mimmi20/ci/.github/workflows/validate.yml@8.3" with: extensions: "ctype, curl, dom, iconv, intl, mbstring, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" @@ -37,7 +37,7 @@ jobs: needs: "validate" - uses: "mimmi20/ci/.github/workflows/install.yml@8.1" + uses: "mimmi20/ci/.github/workflows/install.yml@8.3" with: extensions: "ctype, curl, dom, iconv, intl, mbstring, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" @@ -50,7 +50,7 @@ jobs: needs: "install" - uses: "mimmi20/ci/.github/workflows/analytics.yml@8.1" + uses: "mimmi20/ci/.github/workflows/analytics.yml@8.3" with: extensions: "ctype, curl, dom, iconv, intl, mbstring, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" @@ -59,7 +59,7 @@ jobs: skip-phpcs: false skip-phpstan: false skip-rector: false - skip-phpmd: false + skip-phpmd: true skip-eslint: true skip-stylelint: true skip-prettier: true @@ -70,7 +70,7 @@ jobs: needs: "analytics" - uses: "mimmi20/ci/.github/workflows/test.yml@8.1" + uses: "mimmi20/ci/.github/workflows/test.yml@8.3" with: extensions: "ctype, dom, fileinfo, intl, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index e3d37ab..18b0180 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -11,10 +11,12 @@ declare(strict_types = 1); -$header = <<<'EOF' +$year = date('Y'); + +$header = << + Copyright (c) 2023-{$year}, Thomas Mueller For the full copyright and license information, please view the LICENSE file that was distributed with this source code. diff --git a/codecov.yml b/codecov.yml index d964ea3..9c924a4 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,6 +3,19 @@ codecov: notify: wait_for_ci: false +coverage: + status: + project: + default: # default is the status check's name, not default settings + target: 100% + threshold: 1% + if_ci_failed: success #success, failure, error, ignore + informational: true + only_pulls: false + patch: + default: + informational: true + comment: layout: "reach, diff, flags, files" behavior: default diff --git a/composer.json b/composer.json index 524ca16..3e095a0 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "source": "https://github.com/mimmi20/laminasviewrenderer-revision" }, "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0", "ext-json": "*", "laminas/laminas-uri": "^2.12.0", "laminas/laminas-view": "^2.36.0", @@ -34,16 +34,16 @@ "laminas/laminas-modulemanager": "^2.17.0", "laminas/laminas-servicemanager": "^3.22.1", "mikey179/vfsstream": "^1.6.12", - "mimmi20/coding-standard": "^5.2.45", + "mimmi20/coding-standard": "^6.0.0", "nikic/php-parser": "^5.3.1", "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan": "^1.12.9", "phpstan/phpstan-deprecation-rules": "^1.2.1", "phpstan/phpstan-phpunit": "^1.4.0", - "phpunit/phpunit": "^10.5.25", + "phpunit/phpunit": "^11.4.4", "rector/rector": "^1.2.10", "rector/type-perfect": "^1.0.0", - "symfony/process": "^6.4.15", + "symfony/process": "^7.2.0", "symplify/phpstan-rules": "^13.0.1", "tomasvotruba/cognitive-complexity": "^0.2.3", "tomasvotruba/type-coverage": "^1.0.0", diff --git a/phpmd.ruleset.xml b/phpmd.ruleset.xml deleted file mode 100644 index b7ce722..0000000 --- a/phpmd.ruleset.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - The coding standard. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/phpstan.neon b/phpstan.neon index 9e13926..9a79121 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,8 @@ parameters: level: 1 + phpVersion: 80300 # PHP 8.3 + parallel: maximumNumberOfProcesses: 1 processTimeout: 200.0 @@ -99,9 +101,10 @@ parameters: function: 9 type_coverage: - return: 100 - param: 97.1 - property: 100 + return_type: 100 + param_type: 97.2 + property_type: 100 + constant_type: 100 # also, how many files has declare strict types declare: 100 @@ -121,7 +124,9 @@ parameters: # - '~expects array, array given~' stubFiles: - - vendor/mimmi20/coding-standard/stubs/psr/container/ContainerInterface.stub + - stubs/psr/container/ContainerExceptionInterface.stub + - stubs/psr/container/NotFoundExceptionInterface.stub + - stubs/psr/container/ContainerInterface.stub rules: # code complexity diff --git a/phpunit.xml b/phpunit.xml index 4087f64..3466e22 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,12 +9,14 @@ beStrictAboutCoverageMetadata="false" beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="true" + displayDetailsOnPhpunitDeprecations="true" displayDetailsOnTestsThatTriggerWarnings="true" displayDetailsOnTestsThatTriggerNotices="true" displayDetailsOnTestsThatTriggerErrors="true" displayDetailsOnTestsThatTriggerDeprecations="true" displayDetailsOnSkippedTests="true" displayDetailsOnIncompleteTests="true" + failOnPhpunitDeprecation="true" failOnEmptyTestSuite="true" failOnIncomplete="true" failOnRisky="true" @@ -51,7 +53,7 @@ - + diff --git a/rector.php b/rector.php index 53761c8..f68a7ba 100644 --- a/rector.php +++ b/rector.php @@ -29,7 +29,7 @@ $rectorConfig->sets([ SetList::DEAD_CODE, - LevelSetList::UP_TO_PHP_81, + LevelSetList::UP_TO_PHP_83, PHPUnitSetList::PHPUNIT_100, ]); diff --git a/src/Minify.php b/src/Minify.php index dc4de48..23f914c 100644 --- a/src/Minify.php +++ b/src/Minify.php @@ -14,6 +14,7 @@ namespace Mimmi20\LaminasView\Revision; use JsonException; +use Override; use SplFileInfo; use function array_key_exists; @@ -37,12 +38,12 @@ final class Minify implements MinifyInterface /** * Standardrevision */ - public const DEFAULT_REVISION = '1'; + public const string DEFAULT_REVISION = '1'; /** * Postfix */ - private const REVISION_STRING = '__%s'; + private const string REVISION_STRING = '__%s'; /** * @var array>>|array> @@ -88,6 +89,7 @@ public function __construct( * * @throws void */ + #[Override] public function hasPackage(string $package): bool { return array_key_exists($package, $this->groups); @@ -102,6 +104,7 @@ public function hasPackage(string $package): bool * * @throws void */ + #[Override] public function getPackageFiles(string $package): array { if (!$this->isValid($package)) { @@ -130,6 +133,7 @@ public function getPackageFiles(string $package): array } /** @throws void */ + #[Override] public function isEnabled(): bool { return $this->enabled; @@ -140,6 +144,7 @@ public function isEnabled(): bool * * @throws void */ + #[Override] public function isItemOkToAddRevision(string $type, string $href): bool { if (!$href) { @@ -154,6 +159,7 @@ public function isItemOkToAddRevision(string $type, string $href): bool } /** @throws void */ + #[Override] public function addRevision(string $resource): string { $fileInfo = new SplFileInfo($resource); @@ -167,6 +173,7 @@ public function addRevision(string $resource): string * * @throws void */ + #[Override] public function getRevisionString(): string { return sprintf(self::REVISION_STRING, $this->getRevision()); @@ -177,6 +184,7 @@ public function getRevisionString(): string * * @throws void */ + #[Override] public function getRevision(): string | null { return $this->revision; diff --git a/src/MinifyFactory.php b/src/MinifyFactory.php index 1bba367..6cad40c 100644 --- a/src/MinifyFactory.php +++ b/src/MinifyFactory.php @@ -16,6 +16,7 @@ use JsonException; use Laminas\ServiceManager\Factory\FactoryInterface; use Mimmi20\LaminasView\Revision\Config\MinifyConfigInterface; +use Override; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -34,6 +35,7 @@ final class MinifyFactory implements FactoryInterface * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint */ + #[Override] public function __invoke(ContainerInterface $container, $requestedName, array | null $options = null): Minify { $config = $container->get(MinifyConfigInterface::class); diff --git a/src/MinifyInterface.php b/src/MinifyInterface.php index 1e36c05..dcb28d8 100644 --- a/src/MinifyInterface.php +++ b/src/MinifyInterface.php @@ -18,16 +18,16 @@ */ interface MinifyInterface { - public const FILETYPE_JS = 'js'; + public const string FILETYPE_JS = 'js'; - public const FILETYPE_CSS = 'css'; + public const string FILETYPE_CSS = 'css'; /** * Standardrevision * * @api */ - public const DEFAULT_REVISION = '1'; + public const string DEFAULT_REVISION = '1'; /** * Test for package of given name is known, might by invalid. diff --git a/src/Module.php b/src/Module.php index 3693851..81df81b 100644 --- a/src/Module.php +++ b/src/Module.php @@ -14,6 +14,7 @@ namespace Mimmi20\LaminasView\Revision; use Laminas\ModuleManager\Feature\ConfigProviderInterface; +use Override; final class Module implements ConfigProviderInterface { @@ -23,6 +24,7 @@ final class Module implements ConfigProviderInterface * * @throws void */ + #[Override] public function getConfig(): array { $provider = new ConfigProvider(); diff --git a/src/View/Helper/BaseUrlFactory.php b/src/View/Helper/BaseUrlFactory.php index 13ea496..60fdce6 100644 --- a/src/View/Helper/BaseUrlFactory.php +++ b/src/View/Helper/BaseUrlFactory.php @@ -14,6 +14,7 @@ namespace Mimmi20\LaminasView\Revision\View\Helper; use Laminas\ServiceManager\Factory\FactoryInterface; +use Override; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -34,6 +35,7 @@ final class BaseUrlFactory implements FactoryInterface * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint */ + #[Override] public function __invoke(ContainerInterface $container, $requestedName, array | null $options = null): BaseUrl { $uri = null; diff --git a/src/View/Helper/RevisionHeadLinkFactory.php b/src/View/Helper/RevisionHeadLinkFactory.php index e7d29c6..0620c1e 100644 --- a/src/View/Helper/RevisionHeadLinkFactory.php +++ b/src/View/Helper/RevisionHeadLinkFactory.php @@ -16,6 +16,7 @@ use Laminas\ServiceManager\Factory\FactoryInterface; use Laminas\View\Renderer\PhpRenderer; use Mimmi20\LaminasView\Revision\MinifyInterface; +use Override; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -38,6 +39,7 @@ final class RevisionHeadLinkFactory implements FactoryInterface * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint */ + #[Override] public function __invoke( ContainerInterface $container, $requestedName, diff --git a/src/View/Helper/RevisionHeadScriptFactory.php b/src/View/Helper/RevisionHeadScriptFactory.php index 64ff907..ad9e425 100644 --- a/src/View/Helper/RevisionHeadScriptFactory.php +++ b/src/View/Helper/RevisionHeadScriptFactory.php @@ -16,6 +16,7 @@ use Laminas\ServiceManager\Factory\FactoryInterface; use Laminas\View\Renderer\PhpRenderer; use Mimmi20\LaminasView\Revision\MinifyInterface; +use Override; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -35,6 +36,7 @@ final class RevisionHeadScriptFactory implements FactoryInterface * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint */ + #[Override] public function __invoke( ContainerInterface $container, $requestedName, diff --git a/src/View/Helper/RevisionInlineScriptFactory.php b/src/View/Helper/RevisionInlineScriptFactory.php index fdd8084..4324093 100644 --- a/src/View/Helper/RevisionInlineScriptFactory.php +++ b/src/View/Helper/RevisionInlineScriptFactory.php @@ -16,6 +16,7 @@ use Laminas\ServiceManager\Factory\FactoryInterface; use Laminas\View\Renderer\PhpRenderer; use Mimmi20\LaminasView\Revision\MinifyInterface; +use Override; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -35,6 +36,7 @@ final class RevisionInlineScriptFactory implements FactoryInterface * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint */ + #[Override] public function __invoke( ContainerInterface $container, $requestedName, diff --git a/stubs/psr/container/ContainerExceptionInterface.stub b/stubs/psr/container/ContainerExceptionInterface.stub new file mode 100644 index 0000000..d36a7fe --- /dev/null +++ b/stubs/psr/container/ContainerExceptionInterface.stub @@ -0,0 +1,14 @@ + $id + * @phpstan-param string|class-string $id + * + * @return mixed Entry. + * @psalm-return ($id is class-string ? T : mixed) + * @phpstan-return ($id is class-string ? T : mixed) + * + * @throws NotFoundExceptionInterface No entry was found for **this** identifier. + * @throws ContainerExceptionInterface Error while retrieving the entry. + * + * @template T of object + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint + */ + public function get(string $id); + + /** + * Returns true if the container can return an entry for the given identifier. + * Returns false otherwise. + * + * `has($id)` returning true does not mean that `get($id)` will not throw an exception. + * It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`. + * + * @param string|class-string $id Identifier of the entry to look for. + * + * @return bool + * + * @throws void + * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint + */ + public function has(string $id); +} diff --git a/stubs/psr/container/NotFoundExceptionInterface.stub b/stubs/psr/container/NotFoundExceptionInterface.stub new file mode 100644 index 0000000..272e85a --- /dev/null +++ b/stubs/psr/container/NotFoundExceptionInterface.stub @@ -0,0 +1,12 @@ +object = new MinifyFactory(); diff --git a/tests/View/Helper/BaseUrlFactoryTest.php b/tests/View/Helper/BaseUrlFactoryTest.php index 779434d..0d62ca4 100644 --- a/tests/View/Helper/BaseUrlFactoryTest.php +++ b/tests/View/Helper/BaseUrlFactoryTest.php @@ -15,6 +15,7 @@ use Laminas\Http\PhpEnvironment\Request; use Laminas\Uri\Http; +use Override; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -25,6 +26,7 @@ final class BaseUrlFactoryTest extends TestCase private BaseUrlFactory $object; /** @throws void */ + #[Override] protected function setUp(): void { $this->object = new BaseUrlFactory(); diff --git a/tests/View/Helper/RevisionHeadLinkFactoryTest.php b/tests/View/Helper/RevisionHeadLinkFactoryTest.php index 0fa7af7..c38af6a 100644 --- a/tests/View/Helper/RevisionHeadLinkFactoryTest.php +++ b/tests/View/Helper/RevisionHeadLinkFactoryTest.php @@ -15,6 +15,7 @@ use Laminas\View\Renderer\PhpRenderer; use Mimmi20\LaminasView\Revision\MinifyInterface; +use Override; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -25,6 +26,7 @@ final class RevisionHeadLinkFactoryTest extends TestCase private RevisionHeadLinkFactory $object; /** @throws void */ + #[Override] protected function setUp(): void { $this->object = new RevisionHeadLinkFactory(); diff --git a/tests/View/Helper/RevisionHeadScriptFactoryTest.php b/tests/View/Helper/RevisionHeadScriptFactoryTest.php index e6f2dc1..f62b4ac 100644 --- a/tests/View/Helper/RevisionHeadScriptFactoryTest.php +++ b/tests/View/Helper/RevisionHeadScriptFactoryTest.php @@ -15,6 +15,7 @@ use Laminas\View\Renderer\PhpRenderer; use Mimmi20\LaminasView\Revision\MinifyInterface; +use Override; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -25,6 +26,7 @@ final class RevisionHeadScriptFactoryTest extends TestCase private RevisionHeadScriptFactory $object; /** @throws void */ + #[Override] protected function setUp(): void { $this->object = new RevisionHeadScriptFactory(); diff --git a/tests/View/Helper/RevisionInlineScriptFactoryTest.php b/tests/View/Helper/RevisionInlineScriptFactoryTest.php index f3b0d3d..1fec4d0 100644 --- a/tests/View/Helper/RevisionInlineScriptFactoryTest.php +++ b/tests/View/Helper/RevisionInlineScriptFactoryTest.php @@ -15,6 +15,7 @@ use Laminas\View\Renderer\PhpRenderer; use Mimmi20\LaminasView\Revision\MinifyInterface; +use Override; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -25,6 +26,7 @@ final class RevisionInlineScriptFactoryTest extends TestCase private RevisionInlineScriptFactory $object; /** @throws void */ + #[Override] protected function setUp(): void { $this->object = new RevisionInlineScriptFactory();