Skip to content

Commit

Permalink
Fixes in LegacyReflectionFields.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Oct 10, 2024
1 parent de79548 commit 5c38cb5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Mapping/LegacyReflectionFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function offsetGet($field): mixed
}

if (isset($this->classMetadata->propertyAccessors[$field])) {
$fieldName = str_contains('.', $field) ? $this->classMetadata->fieldMappings[$field]->originalField : $field;
$fieldName = str_contains($field, '.') ? $this->classMetadata->fieldMappings[$field]->originalField : $field;
$className = $this->classMetadata->name;

if (isset($this->classMetadata->fieldMappings[$field]) && $this->classMetadata->fieldMappings[$field]->originalClass !== null) {
Expand All @@ -53,10 +53,18 @@ public function offsetGet($field): mixed
}

if ($this->classMetadata->fieldMappings[$field]->originalField !== null) {
$parentField = str_replace('.' . $fieldName, '', $field);

if (!str_contains($parentField, '.')) {
$parentClass = $this->classMetadata->name;
} else {
$parentClass = $this->classMetadata->fieldMappings[$parentField]->originalClass;
}

$this->reflFields[$field] = new ReflectionEmbeddedProperty(
$this->getAccessibleProperty($parentClass, $parentField),

Check failure on line 65 in src/Mapping/LegacyReflectionFields.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (default)

PossiblyNullArgument

src/Mapping/LegacyReflectionFields.php:65:25: PossiblyNullArgument: Argument 1 of Doctrine\ORM\Mapping\ReflectionEmbeddedProperty::__construct cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 65 in src/Mapping/LegacyReflectionFields.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (default)

ArgumentTypeCoercion

src/Mapping/LegacyReflectionFields.php:65:54: ArgumentTypeCoercion: Argument 1 of Doctrine\ORM\Mapping\LegacyReflectionFields::getAccessibleProperty expects class-string, but parent type null|string provided (see https://psalm.dev/193)

Check failure on line 65 in src/Mapping/LegacyReflectionFields.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (3.8.2)

PossiblyNullArgument

src/Mapping/LegacyReflectionFields.php:65:25: PossiblyNullArgument: Argument 1 of Doctrine\ORM\Mapping\ReflectionEmbeddedProperty::__construct cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 65 in src/Mapping/LegacyReflectionFields.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (3.8.2)

ArgumentTypeCoercion

src/Mapping/LegacyReflectionFields.php:65:54: ArgumentTypeCoercion: Argument 1 of Doctrine\ORM\Mapping\LegacyReflectionFields::getAccessibleProperty expects class-string, but parent type null|string provided (see https://psalm.dev/193)
$this->reflFields[$field],
$this->getAccessibleProperty($this->classMetadata->fieldMappings[$field]->originalClass, $this->classMetadata->fieldMappings[$field]->originalField),
$this->classMetadata->embeddedClasses[$fieldName]->class,
$this->classMetadata->fieldMappings[$field]->originalClass,
);
}
}
Expand Down

0 comments on commit 5c38cb5

Please sign in to comment.