Skip to content

Commit

Permalink
Fix deprecation warning from passing null to str_replace
Browse files Browse the repository at this point in the history
The second argument to `str_replace` should be empty string rather than null. Otherwise you get this error:
```
Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated
```
  • Loading branch information
mkopinsky authored Aug 20, 2024
1 parent 4171901 commit 9b27e8a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Event/Subscriber/DoctrineORMSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function filterEntity(GetFilterConditionEvent $event)

if ($dqlFrom = $event->getQueryBuilder()->getDQLPart('from')) {
$rootPart = reset($dqlFrom);
$fieldName = \str_replace(\sprintf('%s.', $rootPart->getAlias()), null, $event->getField());
$fieldName = \str_replace(\sprintf('%s.', $rootPart->getAlias()), '', $event->getField());
$metadata = $queryBuilder->getEntityManager()->getClassMetadata($rootPart->getFrom());

if (isset($metadata->associationMappings[$fieldName]) && (!$metadata->associationMappings[$fieldName]['isOwningSide'] || $metadata->associationMappings[$fieldName]['type'] === ClassMetadata::MANY_TO_MANY)) {
Expand Down

0 comments on commit 9b27e8a

Please sign in to comment.