Skip to content

Commit

Permalink
minor #6268 Minor change to make some code more readable (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.x branch.

Discussion
----------

Minor change to make some code more readable

PHP-CS-Fixer is complaining about some issue in that line (see https://github.com/EasyCorp/EasyAdminBundle/actions/runs/8726644807/job/23942389012?pr=6267) and the code is a bit complex to read ... so let's simplify it.

Commits
-------

7dea640 Minor change to make some code more readable
  • Loading branch information
javiereguiluz committed Apr 17, 2024
2 parents 4daee20 + 7dea640 commit bb30559
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Filter/Configurator/EntityConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,17 @@ public function configure(FilterDto $filterDto, ?FieldDto $fieldDto, EntityDto $
// because an empty filter value would always return no result
$numberOfRequiredJoinColumns = \count(array_filter(
$doctrineMetadata->get('joinColumns'),
// Doctrine ORM 3.x changed the returned type from array to JoinColumnMapping
static fn (array|JoinColumnMapping $joinColumn): bool => false === (($joinColumn instanceof JoinColumnMapping ? $joinColumn->nullable ?? false : $joinColumn['nullable'] ?? false)))
);
static function (array|JoinColumnMapping $joinColumn): bool {
// Doctrine ORM 3.x changed the returned type from array to JoinColumnMapping
if ($joinColumn instanceof JoinColumnMapping) {
$isNullable = $joinColumn->nullable ?? false;
} else {
$isNullable = $joinColumn['nullable'] ?? false;
}

return false === $isNullable;
}
));

$someJoinColumnsAreNullable = \count($doctrineMetadata->get('joinColumns')) !== $numberOfRequiredJoinColumns;

Expand Down

0 comments on commit bb30559

Please sign in to comment.