Skip to content

Commit

Permalink
Merge branch '2.18.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 2.18.x:
  PHPStan 1.10.59 (doctrine#11320)
  • Loading branch information
derrabus committed Feb 29, 2024
2 parents 95da667 + 4fc8629 commit 20a6efd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -38,7 +38,7 @@
"require-dev": {
"doctrine/coding-standard": "^12.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "1.10.35",
"phpstan/phpstan": "1.10.59",
"phpunit/phpunit": "^10.4.0",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.2",
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Expand Up @@ -30,7 +30,7 @@ parameters:
message: '~^Result of method Doctrine\\DBAL\\Connection::commit\(\) \(void\) is used\.$~'
path: src/UnitOfWork.php
-
message: '~^Strict comparison using === between void and false will always evaluate to false\.$~'
message: '~^Strict comparison using === between null and false will always evaluate to false\.$~'
path: src/UnitOfWork.php
-
message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~'
Expand Down
10 changes: 6 additions & 4 deletions src/Mapping/DefaultTypedFieldMapper.php
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;

/** @psalm-type ScalarName = 'array'|'bool'|'float'|'int'|'string' */
final class DefaultTypedFieldMapper implements TypedFieldMapper
Expand Down Expand Up @@ -52,18 +54,18 @@ public function validateAndComplete(array $mapping, ReflectionProperty $field):
&& ($type instanceof ReflectionNamedType)
) {
if (! $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 20a6efd

Please sign in to comment.