From 3f90574d1c9c3ccfd88454f32b1767b4e8e1b0ed Mon Sep 17 00:00:00 2001 From: Michiel Rook Date: Mon, 8 Nov 2021 14:50:07 +0100 Subject: [PATCH] Fix some phpstan errors --- src/Phing/Io/XmlFileParser.php | 2 +- src/Phing/Target.php | 4 ++-- src/Phing/Task/System/SwitchTask.php | 2 +- src/Phing/Type/CommandlineMarker.php | 4 ++-- tests/Phing/Task/System/ApplyTaskTest.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Phing/Io/XmlFileParser.php b/src/Phing/Io/XmlFileParser.php index 931090177a..396afc4b3e 100644 --- a/src/Phing/Io/XmlFileParser.php +++ b/src/Phing/Io/XmlFileParser.php @@ -91,7 +91,7 @@ private function getProperties(File $file) $prefix = implode('.', $path); - if (!empty($prefix)) { + if (count($prefix) > 0) { $prefix .= '.'; } diff --git a/src/Phing/Target.php b/src/Phing/Target.php index 5f0657c77f..23343e5fb9 100644 --- a/src/Phing/Target.php +++ b/src/Phing/Target.php @@ -318,7 +318,7 @@ public function getTasks() * Set the if-condition from the XML tag, if any. The property name given * as parameter must be present so the if condition evaluates to true. * - * @param string $property The property name that has to be present + * @param string|null $property The property name that has to be present */ public function setIf($property) { @@ -335,7 +335,7 @@ public function getIf() * given as parameter must be present so the unless condition evaluates * to true. * - * @param string $property The property name that has to be present + * @param string|null $property The property name that has to be present */ public function setUnless($property) { diff --git a/src/Phing/Task/System/SwitchTask.php b/src/Phing/Task/System/SwitchTask.php index a58b26262b..52e542171c 100644 --- a/src/Phing/Task/System/SwitchTask.php +++ b/src/Phing/Task/System/SwitchTask.php @@ -152,7 +152,7 @@ public function main() foreach ($this->cases as $case) { $cValue = $case->getValue(); - if (empty($case)) { + if (empty($cValue)) { throw new BuildException('Value is required for case.'); } diff --git a/src/Phing/Type/CommandlineMarker.php b/src/Phing/Type/CommandlineMarker.php index 8e75784fd0..51534c842a 100644 --- a/src/Phing/Type/CommandlineMarker.php +++ b/src/Phing/Type/CommandlineMarker.php @@ -69,7 +69,7 @@ public function getPosition() /** * Set the prefix to be placed in front of the inserted argument. * - * @param string $prefix fixed prefix string + * @param string|null $prefix fixed prefix string */ public function setPrefix($prefix) { @@ -87,7 +87,7 @@ public function getPrefix() /** * Set the suffix to be placed at the end of the inserted argument. * - * @param string $suffix fixed suffix string + * @param string|null $suffix fixed suffix string */ public function setSuffix($suffix) { diff --git a/tests/Phing/Task/System/ApplyTaskTest.php b/tests/Phing/Task/System/ApplyTaskTest.php index 4cc04bda54..496490e9bf 100644 --- a/tests/Phing/Task/System/ApplyTaskTest.php +++ b/tests/Phing/Task/System/ApplyTaskTest.php @@ -453,11 +453,11 @@ public function testMapperSupport(): void /** * @param mixed $value - * @param null $propertyName + * @param string|null $propertyName * * @throws ReflectionException */ - protected function assertAttributeIsSetTo(string $property, $value, $propertyName = null): void + protected function assertAttributeIsSetTo(string $property, $value, string $propertyName = null): void { $task = $this->getConfiguredTask('testPropertySet' . ucfirst($property), ApplyTask::class);