Skip to content

Commit 2a62eaf

Browse files
authored
Merge pull request #397 from AymDev/feature/additionnal-doctrine-attributes
Additional Doctrine attributes
2 parents c463452 + 4047600 commit 2a62eaf

File tree

18 files changed

+353
-20
lines changed

18 files changed

+353
-20
lines changed

phpstan-baseline.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,12 @@
207207
'count' => 1,
208208
'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php',
209209
];
210+
// See https://github.com/phpstan/phpstan/issues/14067
211+
$ignoreErrors[] = [
212+
'message' => '#^Parameter \\#1 \\$provider of class Bazinga\\\\GeocoderBundle\\\\Mapping\\\\ClassMetadata constructor expects non-empty-string, ReflectionMethod\\|ReflectionProperty\\|non-empty-string given\\.$#',
213+
'identifier' => 'argument.type',
214+
'count' => 1,
215+
'path' => __DIR__.'/src/Mapping/Driver/AttributeDriver.php',
216+
];
210217

211218
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

src/Doctrine/ORM/GeocodeEntityListener.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ private function geocodeEntity(ClassMetadata $metadata, object $entity): void
107107
$result = $results->first();
108108
$metadata->latitudeProperty?->setValue($entity, $result->getCoordinates()->getLatitude());
109109
$metadata->longitudeProperty?->setValue($entity, $result->getCoordinates()->getLongitude());
110+
$metadata->northProperty?->setValue($entity, $result->getBounds()?->getNorth());
111+
$metadata->southProperty?->setValue($entity, $result->getBounds()?->getSouth());
112+
$metadata->eastProperty?->setValue($entity, $result->getBounds()?->getEast());
113+
$metadata->westProperty?->setValue($entity, $result->getBounds()?->getWest());
114+
$metadata->streetNumberProperty?->setValue($entity, $result->getStreetNumber());
115+
$metadata->streetNameProperty?->setValue($entity, $result->getStreetName());
116+
$metadata->localityProperty?->setValue($entity, $result->getLocality());
117+
$metadata->postalCodeProperty?->setValue($entity, $result->getPostalCode());
118+
$metadata->subLocalityProperty?->setValue($entity, $result->getSubLocality());
119+
$metadata->countryProperty?->setValue($entity, $result->getCountry());
110120
}
111121
}
112122

src/Mapping/Attributes/Country.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class Country
15+
{
16+
}

src/Mapping/Attributes/East.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class East
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class Locality
15+
{
16+
}

src/Mapping/Attributes/North.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class North
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class PostalCode
15+
{
16+
}

src/Mapping/Attributes/South.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class South
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class StreetName
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class StreetNumber
15+
{
16+
}

0 commit comments

Comments
 (0)