Skip to content

Commit

Permalink
Make PHPStan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 9, 2023
1 parent 5f1562c commit 277ac43
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.15.1",
"phpstan/phpstan": "^1.10.47",
"phpstan/phpstan": "^1.10.48",
"phpstan/phpstan-strict-rules": "^1.5.2",
"phpstan/phpstan-phpunit": "^1.3.15",
"phpstan/phpstan-deprecation-rules": "^1.1.4",
"phpunit/phpunit": "^10.5.1",
"phpunit/phpunit": "^10.5.2",
"symfony/var-dumper": "^6.4.0"
},
"autoload": {
Expand Down
12 changes: 2 additions & 10 deletions src/Enum/Hasser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ public static function hasName(string $name): bool
*/
public static function hasValue(int|string $value): bool
{
if (!(new ReflectionEnum(static::class))->isBacked()) {
return false;
}

foreach (static::cases() as $enum) {
if ($enum->value === $value) { /* @phpstan-ignore-line */
if ($enum?->value === $value) { /* @phpstan-ignore-line */
return true;
}
}
Expand All @@ -65,12 +61,8 @@ public static function hasValue(int|string $value): bool
*/
public static function hasCase(string $name, int|string $value): bool
{
if (!(new ReflectionEnum(static::class))->isBacked()) {
return false;
}

foreach (static::cases() as $enum) {
if ($enum->name === $name && $enum->value === $value) { /* @phpstan-ignore-line */
if ($enum?->name === $name && $enum?->value === $value) { /* @phpstan-ignore-line */
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Enum/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait Info
{
public static function isBacked(): bool
{
return (new ReflectionEnum(static::class))->isBacked();
return (new ReflectionEnum(static::class))->isBacked(); /* @phpstan-ignore-line */
}

public static function isNotBacked(): bool
Expand Down
6 changes: 3 additions & 3 deletions src/Error/CloakTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testErrorTransformedIntoARuntimeException(): void
$touch('/foo');
}

public function testErrorTransformedIntoAnInvalidArgumentException(): void
public function testErrorTransformedIntoAnErrorException(): void
{
Cloak::throwOnError();
$this->expectException(ErrorException::class);
Expand All @@ -96,14 +96,14 @@ public function testSpecificBehaviourOverrideGeneralErrorSetting(): void
$this->expectNotToPerformAssertions();

Cloak::throwOnError();
$touch = Cloak::userDeprecated(touch(...), Cloak::SILENT);
$touch = Cloak::warning(touch(...), Cloak::SILENT);
$touch('/foo');
}

public function testCaptureNothingThrowNoException(): void
{
Cloak::throwOnError();
$strtoupper = Cloak::notice(strtoupper(...));
$strtoupper = Cloak::userDeprecated(strtoupper(...));

self::assertSame('FOO', $strtoupper('foo'));
}
Expand Down

0 comments on commit 277ac43

Please sign in to comment.