From eec25f0955552b3727281d029a8981b97559b7a2 Mon Sep 17 00:00:00 2001 From: Sascha Date: Fri, 17 Jul 2026 07:51:26 +0200 Subject: [PATCH] feat: enable ambiguous-function-call mago rule Fully-qualify the three global function calls (defined, get_class, iterator_to_array) that were resolved ambiguously at compile time, so the ambiguous-function-call linter rule can be turned on instead of disabled. --- mago.toml | 2 +- src/NodeProcessor/AbstractNodeProcessor.php | 2 +- tests/Unit/Behat/NodeProcessor/ArrayNodeProcessorTest.php | 2 +- tests/Unit/XmlProcessorTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mago.toml b/mago.toml index 8656dc6..3a76ed7 100644 --- a/mago.toml +++ b/mago.toml @@ -25,7 +25,7 @@ empty-line-before-return = true integrations = ["phpunit"] [linter.rules] -ambiguous-function-call = { enabled = false } +ambiguous-function-call = { enabled = true } literal-named-argument = { enabled = false } halstead = { effort-threshold = 7000 } final-controller = { enabled = false } diff --git a/src/NodeProcessor/AbstractNodeProcessor.php b/src/NodeProcessor/AbstractNodeProcessor.php index da5f3eb..a8f43b8 100644 --- a/src/NodeProcessor/AbstractNodeProcessor.php +++ b/src/NodeProcessor/AbstractNodeProcessor.php @@ -14,7 +14,7 @@ class AbstractNodeProcessor implements NodeProcessorInterface public function getNodePath(): string { $constName = \get_class($this) . '::NODE_PATH'; - if (!defined($constName)) { + if (!\defined($constName)) { throw new Exception('NODE_PATH not defined in ' . static::class); } diff --git a/tests/Unit/Behat/NodeProcessor/ArrayNodeProcessorTest.php b/tests/Unit/Behat/NodeProcessor/ArrayNodeProcessorTest.php index 46ca9ed..52c73ab 100644 --- a/tests/Unit/Behat/NodeProcessor/ArrayNodeProcessorTest.php +++ b/tests/Unit/Behat/NodeProcessor/ArrayNodeProcessorTest.php @@ -24,7 +24,7 @@ function testGetSubscribedEvents(): void $nodeProcessor = new ArrayNodeProcessor(); $context = $this->getMockBuilder(XmlProcessorContext::class)->disableOriginalConstructor()->getMock(); self::assertIsIterable($nodeProcessor->getSubscribedEvents('test', $context)); - $events = iterator_to_array($nodeProcessor->getSubscribedEvents('test', $context)); + $events = \iterator_to_array($nodeProcessor->getSubscribedEvents('test', $context)); self::assertEquals( [ XmlProcessor::NODE_TYPE_ELEMENT => [$nodeProcessor, 'openElement'], diff --git a/tests/Unit/XmlProcessorTest.php b/tests/Unit/XmlProcessorTest.php index bb01908..284fb40 100644 --- a/tests/Unit/XmlProcessorTest.php +++ b/tests/Unit/XmlProcessorTest.php @@ -35,7 +35,7 @@ public function testGetProcessor(): void $xmlProcessor = new XmlProcessor([$nodeProcessor]); self::assertInstanceOf(TestNodeProcessor::class, $xmlProcessor->getProcessor(TestNodeProcessor::class)); - self::assertInstanceOf(get_class($nodeProcessor), $xmlProcessor->getProcessor(TestNodeProcessor::class)); + self::assertInstanceOf(\get_class($nodeProcessor), $xmlProcessor->getProcessor(TestNodeProcessor::class)); self::assertNull($xmlProcessor->getProcessor(OpenNodeProcessorInterface::class)); }