From e396b1bbeba1d4ec27d08e4f124bee05d7711cc3 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Thu, 25 Sep 2025 13:55:04 +0300 Subject: [PATCH 1/2] Issue #40: Fixed invalid array type assignations reported by PHPStan Signed-off-by: alexmerlin --- src/Component/ClassFile.php | 21 ++++++++++++--------- src/Component/InterfaceFile.php | 21 ++++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Component/ClassFile.php b/src/Component/ClassFile.php index 5ab2551..7cca458 100644 --- a/src/Component/ClassFile.php +++ b/src/Component/ClassFile.php @@ -177,25 +177,28 @@ public function render(): string $class .= PHP_EOL . 'namespace ' . $this->namespace . ';' . PHP_EOL; - sort($this->classUses); - if (count($this->classUses) > 0) { - foreach ($this->classUses as $use) { + $classUses = $this->classUses; + sort($classUses); + if (count($classUses) > 0) { + foreach ($classUses as $use) { $class .= PHP_EOL . $use; } $class .= PHP_EOL; } - sort($this->functionUses); - if (count($this->functionUses) > 0) { - foreach ($this->functionUses as $use) { + $functionUses = $this->functionUses; + sort($functionUses); + if (count($functionUses) > 0) { + foreach ($functionUses as $use) { $class .= PHP_EOL . $use; } $class .= PHP_EOL; } - sort($this->constantUses); - if (count($this->constantUses) > 0) { - foreach ($this->constantUses as $use) { + $constantUses = $this->constantUses; + sort($constantUses); + if (count($constantUses) > 0) { + foreach ($constantUses as $use) { $class .= PHP_EOL . $use; } $class .= PHP_EOL; diff --git a/src/Component/InterfaceFile.php b/src/Component/InterfaceFile.php index 6848049..4f6ccd7 100644 --- a/src/Component/InterfaceFile.php +++ b/src/Component/InterfaceFile.php @@ -128,25 +128,28 @@ public function render(): string $interface .= PHP_EOL . 'namespace ' . $this->namespace . ';' . PHP_EOL; - sort($this->classUses); - if (count($this->classUses) > 0) { - foreach ($this->classUses as $use) { + $classUses = $this->classUses; + sort($classUses); + if (count($classUses) > 0) { + foreach ($classUses as $use) { $interface .= PHP_EOL . $use; } $interface .= PHP_EOL; } - sort($this->functionUses); - if (count($this->functionUses) > 0) { - foreach ($this->functionUses as $use) { + $functionUses = $this->functionUses; + sort($functionUses); + if (count($functionUses) > 0) { + foreach ($functionUses as $use) { $interface .= PHP_EOL . $use; } $interface .= PHP_EOL; } - sort($this->constantUses); - if (count($this->constantUses) > 0) { - foreach ($this->constantUses as $use) { + $constantUses = $this->constantUses; + sort($constantUses); + if (count($constantUses) > 0) { + foreach ($constantUses as $use) { $interface .= PHP_EOL . $use; } $interface .= PHP_EOL; From 53f19f2f8fe19543f2b69d87cfdaee3fbca918b5 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Thu, 25 Sep 2025 13:56:22 +0300 Subject: [PATCH 2/2] Issue #40: Fixed invalid array type assignations reported by PHPStan Signed-off-by: alexmerlin --- src/Component/ClassFile.php | 6 +++--- src/Component/InterfaceFile.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Component/ClassFile.php b/src/Component/ClassFile.php index 7cca458..409fdd2 100644 --- a/src/Component/ClassFile.php +++ b/src/Component/ClassFile.php @@ -178,8 +178,8 @@ public function render(): string $class .= PHP_EOL . 'namespace ' . $this->namespace . ';' . PHP_EOL; $classUses = $this->classUses; - sort($classUses); if (count($classUses) > 0) { + sort($classUses); foreach ($classUses as $use) { $class .= PHP_EOL . $use; } @@ -187,8 +187,8 @@ public function render(): string } $functionUses = $this->functionUses; - sort($functionUses); if (count($functionUses) > 0) { + sort($functionUses); foreach ($functionUses as $use) { $class .= PHP_EOL . $use; } @@ -196,8 +196,8 @@ public function render(): string } $constantUses = $this->constantUses; - sort($constantUses); if (count($constantUses) > 0) { + sort($constantUses); foreach ($constantUses as $use) { $class .= PHP_EOL . $use; } diff --git a/src/Component/InterfaceFile.php b/src/Component/InterfaceFile.php index 4f6ccd7..0067187 100644 --- a/src/Component/InterfaceFile.php +++ b/src/Component/InterfaceFile.php @@ -129,8 +129,8 @@ public function render(): string $interface .= PHP_EOL . 'namespace ' . $this->namespace . ';' . PHP_EOL; $classUses = $this->classUses; - sort($classUses); if (count($classUses) > 0) { + sort($classUses); foreach ($classUses as $use) { $interface .= PHP_EOL . $use; } @@ -138,8 +138,8 @@ public function render(): string } $functionUses = $this->functionUses; - sort($functionUses); if (count($functionUses) > 0) { + sort($functionUses); foreach ($functionUses as $use) { $interface .= PHP_EOL . $use; } @@ -147,8 +147,8 @@ public function render(): string } $constantUses = $this->constantUses; - sort($constantUses); if (count($constantUses) > 0) { + sort($constantUses); foreach ($constantUses as $use) { $interface .= PHP_EOL . $use; }