From 56711f4275531682ef719423edf7f5a6edd1389f Mon Sep 17 00:00:00 2001 From: David Molineus Date: Tue, 20 Feb 2024 15:21:02 +0100 Subject: [PATCH] Drop local phpspec version, update phpcq tools and fix new detected issues. --- .gitattributes | 2 + .gitignore | 4 +- .phpcq.lock | 2 +- .phpcq.yaml.dist | 2 +- .phpcq/local/phpspec-plugin.php | 249 ------------------ .phpcq/local/repository.json | 16 -- composer.json | 1 + psalm.xml | 6 +- .../AbstractFrontendModuleControllerSpec.php | 1 + .../Hybrid/AbstractHybridControllerSpec.php | 1 + src/Controller/AbstractFragmentController.php | 6 +- .../ContentElement/IsHiddenTrait.php | 1 + src/Data/Alias/Filter/AbstractFilter.php | 2 +- src/Data/Alias/Filter/SlugifyFilter.php | 2 +- .../UniqueDatabaseValueValidator.php | 5 +- .../Button/StateButtonCallbackListener.php | 1 + .../Wizard/AbstractWizardListener.php | 2 +- .../Listener/Wizard/PopupWizardListener.php | 1 + src/Dca/Options/CollectionOptions.php | 2 +- src/Security/Csrf/CsrfTokenProvider.php | 2 +- src/View/Assets/GlobalsAssetsManager.php | 16 +- src/View/Template/ToolkitTemplateFactory.php | 4 +- 22 files changed, 35 insertions(+), 293 deletions(-) delete mode 100644 .phpcq/local/phpspec-plugin.php delete mode 100644 .phpcq/local/repository.json diff --git a/.gitattributes b/.gitattributes index 0567f50..a5d902c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,3 +11,5 @@ psalm.xml export-ignore /tests export-ignore /specs export-ignore /docs export-ignore + +phpcq.lock binaryv diff --git a/.gitignore b/.gitignore index 4af9b10..ca387ed 100644 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,7 @@ composer.lock # phpcq .phpcq.yaml -.phpcq/* -!.phpcq -!.phpcq/local +.phpcq #phpcs .phpcs-cache diff --git a/.phpcq.lock b/.phpcq.lock index 2488142..0895670 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.8.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcs-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.7.2","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcs.phar.asc"},"phpcbf":{"version":"3.7.2","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.41.1","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.41.1/composer-normalize.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.41.1/composer-normalize.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.18.0","url":"https://github.com/vimeo/psalm/releases/download/5.18.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.18.0/psalm.phar.asc"}},"composerLock":null},"phpspec":{"api-version":"1.0.0","version":"1.0.0","type":"php-file","url":"./.phpcq/local/phpspec-plugin.php","signature":null,"requirements":{},"checksum":{"type":"sha-512","value":"0307cb00e814c3de436e2c0cc87e4cb949fdec8ce8b3f8fc5a25f7b3631f27dfe8e2b867f4e6419ad4668e252a29267d022c3f6fa20118e4016df66ccfce5605"},"tools":{},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.8.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.9.0","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.0/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.0/phpcs.phar.asc"},"phpcbf":{"version":"3.9.0","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.0/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.0/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.22.1","url":"https://github.com/vimeo/psalm/releases/download/5.22.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.22.1/psalm.phar.asc"}},"composerLock":null},"phpspec":{"api-version":"1.0.0","version":"1.0.0","type":"php-file","url":"./vendor/netzmacht/phpspec-phpcq-plugin/src/phpspec-plugin.php","signature":null,"requirements":{},"checksum":{"type":"sha-512","value":"ad3a8fc0c07f59ad5f522e08d9ebafccb2a215d43c7a4ca8e96b2b05675f00a409406d0ec3c42a0cdf394d98d3d60c747a4d81477f8691cef1eef269fc4b0b8f"},"tools":{},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index 3496142..89aabcd 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -1,6 +1,6 @@ phpcq: repositories: - - ./.phpcq/local/repository.json + - ./vendor/netzmacht/phpspec-phpcq-plugin/repository.json - https://phpcq.github.io/repository/repository.json directories: - src diff --git a/.phpcq/local/phpspec-plugin.php b/.phpcq/local/phpspec-plugin.php deleted file mode 100644 index c9173b8..0000000 --- a/.phpcq/local/phpspec-plugin.php +++ /dev/null @@ -1,249 +0,0 @@ -describeStringOption('config_file', 'The phpspec.yml configuration file') - ->isRequired() - ->withDefaultValue('phpspec.yml'); - - $configOptionsBuilder->describeStringListOption( - 'custom_flags', - 'Any custom flags to pass to phpunit. For valid flags refer to the phpunit documentation.' - ); - - $configOptionsBuilder - ->describeStringOption('phpspec_path', 'The path to the phpspec binary') - ->isRequired() - ->withDefaultValue('vendor/bin/phpspec'); - } - - public function createDiagnosticTasks(PluginConfigurationInterface $config, EnvironmentInterface $environment): iterable - { - $projectRoot = $environment->getProjectConfiguration()->getProjectRootPath(); - yield $environment - ->getTaskFactory() - ->buildPhpProcess('phpspec', $this->buildArguments($config)) - ->withWorkingDirectory($projectRoot) - ->withOutputTransformer($this->createOutputTransformer($projectRoot, $environment)) - ->build(); - } - - private function buildArguments(PluginConfigurationInterface $config): array - { - $arguments = [ - $config->getString('phpspec_path'), - 'run', - '--format=junit', - '-c', - $config->getString('config_file') - ]; - if ($config->has('custom_flags')) { - foreach ($config->getStringList('custom_flags') as $flag) { - $arguments[] = $flag; - } - } - - return $arguments; - } - - private function createOutputTransformer(string $rootDir, EnvironmentInterface $environment): OutputTransformerFactoryInterface - { - return new class($rootDir) implements OutputTransformerFactoryInterface { - /** @var string */ - private $rootDir; - - public function __construct(string $rootDir) { - $this->rootDir = $rootDir; - } - - public function createFor(TaskReportInterface $report): OutputTransformerInterface - { - return new class($report, $this->rootDir) implements OutputTransformerInterface { - /** @var TaskReportInterface $report */ - private $report; - /** @var string */ - private $buffer = ''; - /** @var string */ - private $rootDir; - /** @var string */ - private $errors = ''; - - public function __construct(TaskReportInterface $report, string $rootDir) - { - $this->report = $report; - $this->rootDir = $rootDir; - } - - public function write(string $data, int $channel): void - { - switch ($channel) { - case OutputInterface::CHANNEL_STDOUT: - $this->buffer .= $data; - break; - case OutputInterface::CHANNEL_STDERR: - $this->errors .= $data; - } - } - - public function finish(int $exitCode): void - { - if ($this->errors) { - $this->report - ->addAttachment('error.log') - ->fromString($this->errors) - ->setMimeType('text/plain'); - } - - if (!$this->buffer) { - return; - } - - $xmlDocument = new DOMDocument('1.0'); - $xmlDocument->loadXML($this->buffer); - - $rootNode = $xmlDocument->firstChild; - - if (!$rootNode instanceof DOMNode || $rootNode->nodeName !== 'testsuites') { - return; - } - - foreach ($rootNode->childNodes as $childNode) { - if ((!$childNode instanceof DOMElement) || ($childNode->nodeName !== 'testsuite')) { - continue; - } - $this->walkTestSuite($childNode); - } - - $this->report->close( - $exitCode === 0 ? TaskReportInterface::STATUS_PASSED : TaskReportInterface::STATUS_FAILED - ); - } - - private function walkTestSuite(DOMElement $testsuite): void - { - foreach ($testsuite->childNodes as $childNode) { - if (!$childNode instanceof DOMElement) { - continue; - } - - switch ($childNode->nodeName) { - case 'testsuite': - $this->walkTestSuite($childNode); - break; - case 'testcase': - $this->walkTestCase($childNode, $testsuite->getAttribute('name')); - } - } - } - - private function walkTestCase(DOMElement $testCase, string $testSuite): void - { - $severity = $this->getSeverity($testCase); - if (null === $severity) { - return; - } - - $report = false; - $className = $classFile = $testCase->getAttribute('classname'); - $methodName = str_replace(' ', '_', $testCase->getAttribute('name')); - $source = $this->getSourceInformation($className, $methodName); - if ($source) { - $source = explode(':', $source, 2); - } - - foreach ($testCase->childNodes as $childNode) { - if (!$childNode instanceof DOMElement) { - continue; - } - if (! in_array($childNode->nodeName, ['failure', 'error', 'skipped'])) { - continue; - } - - $report = true; - $builder = $this->report - ->addDiagnostic($severity, $childNode->getAttribute('message')) - ->forClass($testSuite) - ->fromSource($testCase->getAttribute('name')); - - if ($source) { - $builder->forFile($this->stripRootDir($source[0]))->forRange((int) $source[1]); - } - } - - if ($report === false) { - $builder = $this->report - ->addDiagnostic($severity, $testCase->getAttribute('name')) - ->forClass($testSuite) - ->fromSource($className); - - if ($source) { - $builder->forFile($this->stripRootDir($source[0]))->forRange((int) $source[1]); - } - } - } - - /** @psalm-return ?TDiagnosticSeverity */ - private function getSeverity(DOMElement $childNode): ?string - { - switch ($childNode->getAttribute('status')) { - case 'passed': - return TaskReportInterface::SEVERITY_INFO; - - case 'failed': - return TaskReportInterface::SEVERITY_MAJOR; - - case 'broken': - return TaskReportInterface::SEVERITY_MINOR; - - case 'skipped': - case 'pending': - return TaskReportInterface::SEVERITY_MARGINAL; - - default: - return null; - } - } - - private function getSourceInformation(string $className, string $methodName): ?string - { - static $cache = []; - if (isset($cache[$className]) && array_key_exists($methodName, $cache[$className])) { - return $cache[$className]; - } - - $command = '%1$s -r "require \'%2$s/vendor/autoload.php\';' - . 'echo (class_exists(%3$s::class) ? ((new ReflectionClass(%3$s::class))->getFileName() ' - . '. \':\' . (new ReflectionMethod(%3$s::class, \'%4$s\'))->getStartLine())' - . ': \'\');" 2>/dev/null'; - $command = sprintf($command, PHP_BINARY, $this->rootDir, $className, $methodName); - - return $cache[$className][$methodName] = shell_exec($command); - } - - private function stripRootDir(string $content): string - { - return str_replace($this->rootDir . '/', '', $content); - } - }; - } - }; - } -}; diff --git a/.phpcq/local/repository.json b/.phpcq/local/repository.json deleted file mode 100644 index aaa29fc..0000000 --- a/.phpcq/local/repository.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "plugins": { - "phpspec": [ - { - "api-version": "1.0.0", - "version": "1.0.0", - "type": "php-file", - "url": "phpspec-plugin.php", - "checksum": { - "type": "sha-512", - "value": "0307cb00e814c3de436e2c0cc87e4cb949fdec8ce8b3f8fc5a25f7b3631f27dfe8e2b867f4e6419ad4668e252a29267d022c3f6fa20118e4016df66ccfce5605" - } - } - ] - } -} diff --git a/composer.json b/composer.json index 10b9fcb..fe04dac 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,7 @@ "doctrine/coding-standard": "^12.0", "friends-of-phpspec/phpspec-expect": "^4.0", "friendsofsymfony/http-cache": "^2.0", + "netzmacht/phpspec-phpcq-plugin": "@dev", "phpcq/runner-bootstrap": "^1.0@dev", "phpspec/phpspec": "^7.0" }, diff --git a/psalm.xml b/psalm.xml index 4608325..ea7a8c3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -36,11 +36,11 @@ - + - + - + diff --git a/spec/Controller/FrontendModule/AbstractFrontendModuleControllerSpec.php b/spec/Controller/FrontendModule/AbstractFrontendModuleControllerSpec.php index 5c94033..7585e36 100644 --- a/spec/Controller/FrontendModule/AbstractFrontendModuleControllerSpec.php +++ b/spec/Controller/FrontendModule/AbstractFrontendModuleControllerSpec.php @@ -37,6 +37,7 @@ public function let( System::setContainer($container->getWrappedObject()); $router->generate(Argument::cetera())->willReturn('https://example.org'); + $translator->trans(Argument::cetera())->willReturn('TRANSLATED'); $container->getParameter('kernel.cache_dir')->willReturn(__DIR__ . '/../../fixtures'); $container->getParameter('kernel.debug')->willReturn(false); diff --git a/spec/Controller/Hybrid/AbstractHybridControllerSpec.php b/spec/Controller/Hybrid/AbstractHybridControllerSpec.php index 38196f1..ef65153 100644 --- a/spec/Controller/Hybrid/AbstractHybridControllerSpec.php +++ b/spec/Controller/Hybrid/AbstractHybridControllerSpec.php @@ -44,6 +44,7 @@ public function let( $container->getParameter('kernel.debug')->willReturn(false); $router->generate(Argument::cetera())->willReturn('https://example.org'); + $translator->trans(Argument::cetera())->willReturn('TRANSLATED'); $this->beAnInstanceOf(ConcreteHybridController::class); $this->beConstructedWith( diff --git a/src/Controller/AbstractFragmentController.php b/src/Controller/AbstractFragmentController.php index f09a4fc..8ce14af 100644 --- a/src/Controller/AbstractFragmentController.php +++ b/src/Controller/AbstractFragmentController.php @@ -128,9 +128,9 @@ protected function generate(Request $request, Model $model, string $section, arr */ private function prepareDefaultTemplateData(Model $model, string $section, array|null $classes = null): array { - $data = $model->row(); - $cssID = array_pad(StringUtil::deserialize($data['cssID'], true), 2, ''); - $classes = $classes ?: []; + $data = $model->row(); + $cssID = array_pad(StringUtil::deserialize($data['cssID'], true), 2, ''); + $classes ??= []; if ($cssID[1] !== '') { array_unshift($classes, $cssID[1]); diff --git a/src/Controller/ContentElement/IsHiddenTrait.php b/src/Controller/ContentElement/IsHiddenTrait.php index 3a886bf..e0438de 100644 --- a/src/Controller/ContentElement/IsHiddenTrait.php +++ b/src/Controller/ContentElement/IsHiddenTrait.php @@ -30,6 +30,7 @@ trait IsHiddenTrait */ protected function isHidden(ContentModel $model, Request $request): bool { + /** @psalm-suppress RiskyTruthyFalsyComparison */ $isInvisible = $model->invisible || ($model->start && $model->start > time()) || ($model->stop && $model->stop <= time()); diff --git a/src/Data/Alias/Filter/AbstractFilter.php b/src/Data/Alias/Filter/AbstractFilter.php index c5082a6..820c34c 100644 --- a/src/Data/Alias/Filter/AbstractFilter.php +++ b/src/Data/Alias/Filter/AbstractFilter.php @@ -41,7 +41,7 @@ public function initialize(): void */ protected function combine(string|null $previous, string|null $current, string $separator): string|null { - if (! $previous || ! $current) { + if ($previous === null || $current === null) { return $current; } diff --git a/src/Data/Alias/Filter/SlugifyFilter.php b/src/Data/Alias/Filter/SlugifyFilter.php index 337bfa9..b324eb4 100644 --- a/src/Data/Alias/Filter/SlugifyFilter.php +++ b/src/Data/Alias/Filter/SlugifyFilter.php @@ -25,7 +25,7 @@ final class SlugifyFilter extends AbstractValueFilter * @param list $columns Columns being used for the value. * @param bool $break If true break after the filter if value is unique. * @param int $combine Combine flag. - * @param bool|mixed $preserveUppercase If true uppercase values are not transformed. + * @param bool $preserveUppercase If true uppercase values are not transformed. * @param string $charset Encoding charset. */ public function __construct( diff --git a/src/Data/Alias/Validator/UniqueDatabaseValueValidator.php b/src/Data/Alias/Validator/UniqueDatabaseValueValidator.php index 2afe02d..6033fb9 100644 --- a/src/Data/Alias/Validator/UniqueDatabaseValueValidator.php +++ b/src/Data/Alias/Validator/UniqueDatabaseValueValidator.php @@ -4,6 +4,7 @@ namespace Netzmacht\Contao\Toolkit\Data\Alias\Validator; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; use Netzmacht\Contao\Toolkit\Data\Alias\Validator; @@ -79,9 +80,9 @@ public function validate(object $result, mixed $value, array|null $exclude = nul $builder->setParameter($field, $result->$field); } - if ($exclude) { + if ($exclude !== null) { $builder->andWhere('id NOT IN(:excluded)'); - $builder->setParameter('excluded', $exclude, Connection::PARAM_INT_ARRAY); + $builder->setParameter('excluded', $exclude, ArrayParameterType::INTEGER); } return (int) $builder->fetchOne() === 0; diff --git a/src/Dca/Listener/Button/StateButtonCallbackListener.php b/src/Dca/Listener/Button/StateButtonCallbackListener.php index 73ac5be..e6a6183 100644 --- a/src/Dca/Listener/Button/StateButtonCallbackListener.php +++ b/src/Dca/Listener/Button/StateButtonCallbackListener.php @@ -105,6 +105,7 @@ public function onButtonCallback( $name = $this->getOperationName((string) $attributes); $config = $this->getConfig($dataContainer, $name); + /** @psalm-suppress RiskyTruthyFalsyComparison */ if ($this->input->get('tid')) { try { /** @psalm-suppress RiskyCast */ diff --git a/src/Dca/Listener/Wizard/AbstractWizardListener.php b/src/Dca/Listener/Wizard/AbstractWizardListener.php index eff73f1..ed0ac0e 100644 --- a/src/Dca/Listener/Wizard/AbstractWizardListener.php +++ b/src/Dca/Listener/Wizard/AbstractWizardListener.php @@ -66,7 +66,7 @@ public function __construct( */ protected function render(string|null $name = null, array $parameters = []): string { - return $this->templateEngine->render($name ?: $this->template, $parameters); + return $this->templateEngine->render($name ?? $this->template, $parameters); } /** diff --git a/src/Dca/Listener/Wizard/PopupWizardListener.php b/src/Dca/Listener/Wizard/PopupWizardListener.php index 09bf9e3..6aba251 100644 --- a/src/Dca/Listener/Wizard/PopupWizardListener.php +++ b/src/Dca/Listener/Wizard/PopupWizardListener.php @@ -84,6 +84,7 @@ public function generate(mixed $value, array $config = []): string $config, ); + /** @psalm-suppress RiskyTruthyFalsyComparison */ if ($config['always'] || $value) { $token = $this->csrfTokenManager->getToken($this->tokenName)->getValue(); parse_str((string) $config['href'], $params); diff --git a/src/Dca/Options/CollectionOptions.php b/src/Dca/Options/CollectionOptions.php index 3e4d8d7..f70fbfb 100644 --- a/src/Dca/Options/CollectionOptions.php +++ b/src/Dca/Options/CollectionOptions.php @@ -40,7 +40,7 @@ public function __construct( callable|string|null $labelColumn = null, private readonly string $valueColumn = 'id', ) { - $this->labelColumn = $labelColumn ?: $valueColumn; + $this->labelColumn = $labelColumn ?? $valueColumn; } /** diff --git a/src/Security/Csrf/CsrfTokenProvider.php b/src/Security/Csrf/CsrfTokenProvider.php index e6cfdc9..270ac60 100644 --- a/src/Security/Csrf/CsrfTokenProvider.php +++ b/src/Security/Csrf/CsrfTokenProvider.php @@ -41,7 +41,7 @@ public function __construct(CsrfTokenManagerInterface $tokenManager, string $def */ public function getToken(string|null $name = null): CsrfToken { - return $this->tokenManager->getToken($name ?: $this->defaultTokenName); + return $this->tokenManager->getToken($name ?? $this->defaultTokenName); } /** diff --git a/src/View/Assets/GlobalsAssetsManager.php b/src/View/Assets/GlobalsAssetsManager.php index 5255758..9f3fa5c 100644 --- a/src/View/Assets/GlobalsAssetsManager.php +++ b/src/View/Assets/GlobalsAssetsManager.php @@ -83,10 +83,10 @@ public function addJavascript( $path .= '|static'; } - if ($name) { - $this->javascripts[$name] = $path; - } else { + if ($name === null) { $this->javascripts[] = $path; + } else { + $this->javascripts[$name] = $path; } return $this; @@ -99,7 +99,7 @@ public function addJavascripts( string|null $name = null, ): AssetsManager { foreach ($paths as $identifier => $path) { - if ($name) { + if ($name !== null && $name !== '') { $name .= '_' . $identifier; } elseif (! is_numeric($identifier)) { $name = $identifier; @@ -129,10 +129,10 @@ public function addStylesheet( } } - if ($name) { - $this->stylesheets[$name] = $path; - } else { + if ($name === null) { $this->stylesheets[] = $path; + } else { + $this->stylesheets[$name] = $path; } return $this; @@ -146,7 +146,7 @@ public function addStylesheets( string|null $name = null, ): AssetsManager { foreach ($paths as $identifier => $path) { - if ($name) { + if ($name !== null && $name !== '') { $name .= '_' . $identifier; } elseif (! is_numeric($identifier)) { $name = $identifier; diff --git a/src/View/Template/ToolkitTemplateFactory.php b/src/View/Template/ToolkitTemplateFactory.php index 79c37a1..dac6def 100644 --- a/src/View/Template/ToolkitTemplateFactory.php +++ b/src/View/Template/ToolkitTemplateFactory.php @@ -37,7 +37,7 @@ public function createFrontendTemplate( $helpers = $this->getTemplateHelpers($name, $contentType); $template = new FrontendTemplate($name, $helpers, $contentType); - if ($data) { + if ($data !== null) { $template->setData($data); } @@ -57,7 +57,7 @@ public function createBackendTemplate( $helpers = $this->getTemplateHelpers($name, $contentType); $template = new BackendTemplate($name, $helpers, $contentType); - if ($data) { + if ($data !== null) { $template->setData($data); }