From f7f5d68351ee3242258d5b8d8bd08ecdcddf2a9d Mon Sep 17 00:00:00 2001 From: mondrake <1174864+mondrake@users.noreply.github.com> Date: Sun, 21 Sep 2025 19:07:10 +0000 Subject: [PATCH] fix PHPStan errors --- src/Map/BaseMap.php | 8 -------- tests/src/MapHandlerTest.php | 1 - tests/src/MapUpdaterTest.php | 5 ----- 3 files changed, 14 deletions(-) diff --git a/src/Map/BaseMap.php b/src/Map/BaseMap.php index b3fd8d32..4d263c01 100644 --- a/src/Map/BaseMap.php +++ b/src/Map/BaseMap.php @@ -75,7 +75,6 @@ public function getMapArray(): array public function sort(): MapInterface { foreach (array_keys(static::$map) as $k) { - // @phpstan-ignore assign.propertyType ksort(static::$map[$k]); foreach (static::$map[$k] as &$sub) { ksort($sub); @@ -166,11 +165,9 @@ protected function getMapSubEntry(string $entry, string $entryKey, string $subEn protected function addMapSubEntry(string $entry, string $entryKey, string $subEntry, string $value): MapInterface { if (!isset(static::$map[$entry][$entryKey][$subEntry])) { - // @phpstan-ignore assign.propertyType static::$map[$entry][$entryKey][$subEntry] = [$value]; } else { if (array_search($value, static::$map[$entry][$entryKey][$subEntry]) === false) { - // @phpstan-ignore assign.propertyType static::$map[$entry][$entryKey][$subEntry][] = $value; } } @@ -206,12 +203,10 @@ protected function removeMapSubEntry(string $entry, string $entryKey, string $su } // Remove the map sub entry key. - // @phpstan-ignore assign.propertyType unset(static::$map[$entry][$entryKey][$subEntry][$k]); // Remove the sub entry if no more values. if (empty(static::$map[$entry][$entryKey][$subEntry])) { - // @phpstan-ignore assign.propertyType unset(static::$map[$entry][$entryKey][$subEntry]); } else { // Resequence the remaining values. @@ -219,13 +214,11 @@ protected function removeMapSubEntry(string $entry, string $entryKey, string $su foreach (static::$map[$entry][$entryKey][$subEntry] as $v) { $tmp[] = $v; } - // @phpstan-ignore assign.propertyType static::$map[$entry][$entryKey][$subEntry] = $tmp; } // Remove the entry if no more values. if (empty(static::$map[$entry][$entryKey])) { - // @phpstan-ignore assign.propertyType unset(static::$map[$entry][$entryKey]); } @@ -269,7 +262,6 @@ protected function setValueAsDefault(string $entry, string $entryKey, string $su } $tmp[] = $v; } - // @phpstan-ignore assign.propertyType static::$map[$entry][$entryKey][$subEntry] = $tmp; return $this; diff --git a/tests/src/MapHandlerTest.php b/tests/src/MapHandlerTest.php index 0fe3546c..5908879e 100644 --- a/tests/src/MapHandlerTest.php +++ b/tests/src/MapHandlerTest.php @@ -28,7 +28,6 @@ public function testSetDefaultMapClass(): void MapHandler::setDefaultMapClass(EmptyMap::class); $this->assertInstanceOf(EmptyMap::class, MapHandler::map()); MapHandler::setDefaultMapClass(DefaultMap::class); - // @phpstan-ignore method.impossibleType $this->assertInstanceOf(DefaultMap::class, MapHandler::map()); } diff --git a/tests/src/MapUpdaterTest.php b/tests/src/MapUpdaterTest.php index 19d669f7..638bc941 100644 --- a/tests/src/MapUpdaterTest.php +++ b/tests/src/MapUpdaterTest.php @@ -49,7 +49,6 @@ public function testLoadMapFromApacheFile(): void 'txt' => ['t' => ['text/plain']], ], ]; - // @phpstan-ignore method.impossibleType $this->assertSame($expected, $this->newMap->getMapArray()); $this->assertSame(['image/jpeg', 'text/plain'], $this->newMap->listTypes()); $this->assertSame(['jpe', 'jpeg', 'jpg', 'txt'], $this->newMap->listExtensions()); @@ -111,7 +110,6 @@ public function testLoadMapFromFreedesktopFile(): void 'image/pdf' => ['t' => ['application/pdf']], ], ]; - // @phpstan-ignore method.impossibleType $this->assertSame($expected, $this->newMap->getMapArray()); $this->assertSame(['application/pdf', 'application/x-atari-2600-rom', 'application/x-pdf', 'text/plain'], $this->newMap->listTypes()); $this->assertSame(['a26', 'asc', 'pdf', 'txt'], $this->newMap->listExtensions()); @@ -121,7 +119,6 @@ public function testLoadMapFromFreedesktopFile(): void public function testLoadMapFromFreedesktopFileZeroLines(): void { $this->updater->loadMapFromFreedesktopFile(dirname(__FILE__) . '/../fixtures/zero.freedesktop.xml'); - // @phpstan-ignore method.impossibleType $this->assertSame([], $this->newMap->getMapArray()); } @@ -149,7 +146,6 @@ public function testWriteMapToPhpClassFile(): void { $this->fileSystem->copy(__DIR__ . '/../fixtures/MiniMap.php.test', __DIR__ . '/../fixtures/MiniMap.php'); include_once(__DIR__ . '/../fixtures/MiniMap.php'); - // @phpstan-ignore class.notFound, argument.type MapHandler::setDefaultMapClass(MiniMap::class); $map_a = MapHandler::map(); $this->assertStringContainsString('fixtures/MiniMap.php', $map_a->getFileName()); @@ -171,7 +167,6 @@ public function testWriteMapToPhpClassFileFailure(): void { $this->fileSystem->copy(__DIR__ . '/../fixtures/MiniMap.php.test', __DIR__ . '/../fixtures/MiniMap.php'); include_once(__DIR__ . '/../fixtures/MiniMap.php'); - // @phpstan-ignore class.notFound, argument.type MapHandler::setDefaultMapClass(MiniMap::class); $map_a = MapHandler::map(); $this->assertStringContainsString('fixtures/MiniMap.php', $map_a->getFileName());