Skip to content

Commit

Permalink
PHPStan 1.10.59
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Feb 29, 2024
1 parent feb27f0 commit ab2c140
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"doctrine/annotations": "^1.13 || ^2",
"doctrine/coding-standard": "^9.0.2 || ^12.0",
"phpbench/phpbench": "^0.16.10 || ^1.0",
"phpstan/phpstan": "~1.4.10 || 1.10.35",
"phpstan/phpstan": "~1.4.10 || 1.10.59",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.2",
Expand Down
16 changes: 3 additions & 13 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ parameters:
path: src/Mapping/Driver/XmlDriver.php

-
message: "#^Offset 'version' on \\*NEVER\\* in isset\\(\\) always exists and is always null\\.$#"
message: "#^Offset 'version' on \\*NEVER\\* in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: src/Mapping/Driver/XmlDriver.php

Expand Down Expand Up @@ -326,7 +326,7 @@ parameters:
path: src/Query/AST/Functions/DateSubFunction.php

-
message: "#^Method Doctrine\\\\ORM\\\\Query\\\\AST\\\\IndexBy\\:\\:dispatch\\(\\) should return string but returns void\\.$#"
message: "#^Method Doctrine\\\\ORM\\\\Query\\\\AST\\\\IndexBy\\:\\:dispatch\\(\\) should return string but returns null\\.$#"
count: 1
path: src/Query/AST/IndexBy.php

Expand Down Expand Up @@ -375,11 +375,6 @@ parameters:
count: 1
path: src/Query/Expr/Select.php

-
message: "#^Comparison operation \"\\<\" between null and 102 is always true\\.$#"
count: 1
path: src/Query/Parser.php

-
message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:ArithmeticFactor\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticFactor but returns Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\|string\\.$#"
count: 1
Expand All @@ -395,14 +390,9 @@ parameters:
count: 1
path: src/Query/Parser.php

-
message: "#^Result of && is always true\\.$#"
count: 1
path: src/Query/Parser.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 4
count: 3
path: src/Query/Parser.php

-
Expand Down
10 changes: 6 additions & 4 deletions src/Mapping/DefaultTypedFieldMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\ORM\Mapping;

use BackedEnum;
use DateInterval;
use DateTime;
use DateTimeImmutable;
Expand All @@ -16,6 +17,7 @@
use function array_merge;
use function assert;
use function enum_exists;
use function is_a;

use const PHP_VERSION_ID;

Expand Down Expand Up @@ -54,18 +56,18 @@ public function validateAndComplete(array $mapping, ReflectionProperty $field):
&& ($type instanceof ReflectionNamedType)
) {
if (PHP_VERSION_ID >= 80100 && ! $type->isBuiltin() && enum_exists($type->getName())) {
$mapping['enumType'] = $type->getName();

$reflection = new ReflectionEnum($type->getName());
if (! $reflection->isBacked()) {
throw MappingException::backedEnumTypeRequired(
$field->class,
$mapping['fieldName'],
$mapping['enumType']
$type->getName(),
);
}

$type = $reflection->getBackingType();
assert(is_a($type->getName(), BackedEnum::class, true));
$mapping['enumType'] = $type->getName();
$type = $reflection->getBackingType();

assert($type instanceof ReflectionNamedType);
}
Expand Down

0 comments on commit ab2c140

Please sign in to comment.