Open
Description
We use the following mess detector ruleset:
magento/magento2-functional-testing-framework/dev/tests/static/Magento/CodeMessDetector/ruleset.xml
When running mess detector with this ruleset, we encounter the following fatal error on PHP 8.4.8:
Fatal error: Declaration of Magento\CodeMessDetector\Rule\Design\FinalImplementation::apply(PHPMD\AbstractNode $node) must be compatible with PHPMD\Rule::apply(PHPMD\AbstractNode $node): void in ./vendor/magento/magento2-functional-testing-framework/dev/tests/static/Magento/CodeMessDetector/Rule/Design/FinalImplementation.php on line 23
Environment:
- Magento: 2.4.8-p1
- magento/magento2-functional-testing-framework: 5.0.5
- phpmd/phpmd: 3.x-dev
- PHP: 8.4.8
A vanilla Magento install has a dev dependency for phpmd/phpmd 3.x-dev and this introduces the fatal error: https://github.com/magento/magento2/blob/2.4.8-p1/composer.json
Cause:
The method signature for apply()
in FinalImplementation
does not include the required : void
return type, which is now enforced.
Patch:
diff --git a/dev/tests/static/Magento/CodeMessDetector/Rule/Design/FinalImplementation.php b/dev/tests/static/Magento/CodeMessDetector/Rule/Design/FinalImplementation.php
index 4b9c99e..c1db5e3 100644
--- a/dev/tests/static/Magento/CodeMessDetector/Rule/Design/FinalImplementation.php
+++ b/dev/tests/static/Magento/CodeMessDetector/Rule/Design/FinalImplementation.php
@@ -16,11 +16,13 @@
*/
class FinalImplementation extends AbstractRule implements ClassAware, MethodAware
{
/**
* @inheritdoc
*/
- public function apply(AbstractNode $node)
+ public function apply(AbstractNode $node): void
{
if ($node->isFinal()) {
$this->addViolation($node, [$node->getType(), $node->getFullQualifiedName()]);
}
}
}
Please update the method signature to ensure compatibility with PHP 8.4 and newer PHPMD versions.
Metadata
Metadata
Assignees
Labels
No labels