Skip to content

Conversation

michaelKaefer
Copy link
Contributor

Another refactoring. Please just tell me if you have better things to do than checking my refactoring PRs 😬

Notes:

  • I paid a lot of attention to not break anything and not change any existing behaviour of the code
  • I deprecated the methods because they are just wrappers over ClassMetadata and provide no extra value IMHO. If they don't exist anymore there is less EA code to maintain and IMHO the client code is easier to follow if there is no extra wrapper between Doctrine and the client code.
  • getPropertyDataType() is not only a wrapper over ClassMetadata but also mixes FieldMapping with AssociationMapping and so it returns sometimes string sometimes int -> so it makes things even more complicated than just using ClassMetadata itself. I also plan a PR for deprecating getPropertyMetadata (in the first place because it mixes FieldMapping with AssociationMapping).
  • I replaced some \array_key_exists with isset simply because Doctrine ORM (and also Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser) checks the same thing with isset instead of \array_key_exists
  • in 4.0.0 my change introduces 9 times the following code which looks a little ugly:
// Doctrine ORM 2.x returns an array and Doctrine ORM 3.x returns a FieldMapping object
/** @var FieldMapping|array $fieldMapping */
/** @phpstan-ignore-next-line */
$fieldMapping = $entityDto->getClassMetadata()->getFieldMapping($propertyName);
if (\is_array($fieldMapping)) {
    $type = $fieldMapping['type'];
} else {
    $type = $fieldMapping->type;
}

But in 5.0.0 all occurances can be changed from 9 lines to 1 line:

$type = $entityDto->getClassMetadata()->getFieldMapping($propertyName)->type;

@javiereguiluz javiereguiluz added this to the 4.x milestone Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants