Skip to content

Commit bdffbba

Browse files
committed
make PHPStan happy
1 parent 09dd943 commit bdffbba

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090

9191
- name: Run PHPStan
9292
if: ${{ matrix.RUN_PHPSTAN }}
93-
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php ./vendor/bin/phpstan analyse --level max src/ tests/
93+
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/
9494

9595
- name: Run psalm
9696
if: ${{ matrix.RUN_PSALM }}

src/Enum.php

+2
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ final public static function getConstants()
392392
$constants = $scopeConstants + $constants;
393393
} while (($reflection = $reflection->getParentClass()) && $reflection->name !== __CLASS__);
394394

395+
/** @var array<string, null|bool|int|float|string|array<mixed>> $constants */
396+
395397
assert(
396398
self::noAmbiguousValues($constants),
397399
'Ambiguous enumerator values detected for ' . static::class

tests/MabeEnumTest/EnumMapTest.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,13 @@ public function testSerializable(): void
477477

478478
public function testIsEmpty(): void
479479
{
480-
/** @var array<int, string> $items2 */
481-
$items2 = array_combine(Enum32::getValues(), Enum32::getNames());
480+
$makeItems2 = function () {
481+
foreach (Enum32::getEnumerators() as $enumerator) {
482+
yield $enumerator => $enumerator->getName();
483+
}
484+
};
482485
$map1 = new EnumMap(Enum32::class, []);
483-
$map2 = new EnumMap(Enum32::class, $items2);
486+
$map2 = new EnumMap(Enum32::class, $makeItems2());
484487

485488
$this->assertTrue($map1->isEmpty());
486489
$this->assertFalse($map2->isEmpty());

0 commit comments

Comments
 (0)