Skip to content

Commit 20a6efd

Browse files
committed
Merge branch '2.18.x' into 3.0.x
* 2.18.x: PHPStan 1.10.59 (#11320)
2 parents 95da667 + 4fc8629 commit 20a6efd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"require-dev": {
3939
"doctrine/coding-standard": "^12.0",
4040
"phpbench/phpbench": "^1.0",
41-
"phpstan/phpstan": "1.10.35",
41+
"phpstan/phpstan": "1.10.59",
4242
"phpunit/phpunit": "^10.4.0",
4343
"psr/log": "^1 || ^2 || ^3",
4444
"squizlabs/php_codesniffer": "3.7.2",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ parameters:
3030
message: '~^Result of method Doctrine\\DBAL\\Connection::commit\(\) \(void\) is used\.$~'
3131
path: src/UnitOfWork.php
3232
-
33-
message: '~^Strict comparison using === between void and false will always evaluate to false\.$~'
33+
message: '~^Strict comparison using === between null and false will always evaluate to false\.$~'
3434
path: src/UnitOfWork.php
3535
-
3636
message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~'

src/Mapping/DefaultTypedFieldMapper.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\ORM\Mapping;
66

7+
use BackedEnum;
78
use DateInterval;
89
use DateTime;
910
use DateTimeImmutable;
@@ -16,6 +17,7 @@
1617
use function array_merge;
1718
use function assert;
1819
use function enum_exists;
20+
use function is_a;
1921

2022
/** @psalm-type ScalarName = 'array'|'bool'|'float'|'int'|'string' */
2123
final class DefaultTypedFieldMapper implements TypedFieldMapper
@@ -52,18 +54,18 @@ public function validateAndComplete(array $mapping, ReflectionProperty $field):
5254
&& ($type instanceof ReflectionNamedType)
5355
) {
5456
if (! $type->isBuiltin() && enum_exists($type->getName())) {
55-
$mapping['enumType'] = $type->getName();
56-
5757
$reflection = new ReflectionEnum($type->getName());
5858
if (! $reflection->isBacked()) {
5959
throw MappingException::backedEnumTypeRequired(
6060
$field->class,
6161
$mapping['fieldName'],
62-
$mapping['enumType'],
62+
$type->getName(),
6363
);
6464
}
6565

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

6870
assert($type instanceof ReflectionNamedType);
6971
}

0 commit comments

Comments
 (0)