Skip to content

Commit ca1bf71

Browse files
authored
replace empty() check
when searching for an address that returns no result, an AddressCollection item is returned with no locations inside, which means locations is an empty array, so the next line which reads the first result will cause an exception when there is no location. it is better to use the isEmpty() method of the AddressCollection to no try to access the first entry when there is no such entry
1 parent f6a4796 commit ca1bf71

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doctrine/ORM/GeocoderListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function geocodeEntity($entity)
100100

101101
$results = $this->geocoder->geocodeQuery(GeocodeQuery::create($address));
102102

103-
if (!empty($results)) {
103+
if (!$results->isEmpty()) {
104104
$result = $results->first();
105105
$metadata->latitudeProperty->setValue($entity, $result->getCoordinates()->getLatitude());
106106
$metadata->longitudeProperty->setValue($entity, $result->getCoordinates()->getLongitude());

0 commit comments

Comments
 (0)