Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"willdurand/geocoder": "^4.6|^5.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.3",
"doctrine/doctrine-bundle": "^2.18 || ^3.0",
"doctrine/orm": "^2.20 || ^3.0",
"fakerphp/faker": "^1.20",
"friendsofphp/php-cs-fixer": "^3.13",
Expand Down
68 changes: 35 additions & 33 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -1,197 +1,199 @@
<?php declare(strict_types = 1);
<?php

declare(strict_types=1);

$ignoreErrors = [];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$name of method Geocoder\\\\ProviderAggregator\\:\\:using\\(\\) expects string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Command/GeocodeCommand.php',
'path' => __DIR__.'/src/Command/GeocodeCommand.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$string of function strtolower expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Command/GeocodeCommand.php',
'path' => __DIR__.'/src/Command/GeocodeCommand.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$text of static method Geocoder\\\\Query\\\\GeocodeQuery\\:\\:create\\(\\) expects string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Command/GeocodeCommand.php',
'path' => __DIR__.'/src/Command/GeocodeCommand.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Command/GeocodeCommand.php',
'path' => __DIR__.'/src/Command/GeocodeCommand.php',
];
$ignoreErrors[] = [
// identifier: foreach.nonIterable
'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#',
'count' => 3,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset \'aliases\' on mixed\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset \'enabled\' on mixed\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset \'factory\' on mixed\\.$#',
'count' => 5,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset \'id\' on mixed\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset \'options\' on mixed\\.$#',
'count' => 4,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset \'reference\' on mixed\\.$#',
'count' => 2,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: staticMethod.nonObject
'message' => '#^Cannot call static method validate\\(\\) on mixed\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: cast.string
'message' => '#^Cannot cast mixed to string\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$alias of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:setAlias\\(\\) expects string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: Symfony\\\\Component\\\\DependencyInjection\\\\Reference given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$factoryServiceId of static method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\Compiler\\\\FactoryValidatorPass\\:\\:addFactoryServiceId\\(\\) expects string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$id of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:getDefinition\\(\\) expects string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$object_or_class of function class_implements expects object\\|string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$options of method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\BazingaGeocoderExtension\\:\\:findReferences\\(\\) expects array\\<int\\|string, mixed\\>, mixed given\\.$#',
'count' => 2,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$string of function ltrim expects string, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#2 \\$config of method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\BazingaGeocoderExtension\\:\\:configureProviderPlugins\\(\\) expects array\\<int\\|string, mixed\\>, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: encapsedStringPart.nonString
'message' => '#^Part \\$providerName \\(mixed\\) of encapsed string cannot be cast to string\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DependencyInjection/BazingaGeocoderExtension.php',
'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method getLatitude\\(\\) on Geocoder\\\\Model\\\\Coordinates\\|null\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Doctrine/ORM/GeocoderListener.php',
'path' => __DIR__.'/src/Doctrine/ORM/GeocoderListener.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method getLongitude\\(\\) on Geocoder\\\\Model\\\\Coordinates\\|null\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Doctrine/ORM/GeocoderListener.php',
'path' => __DIR__.'/src/Doctrine/ORM/GeocoderListener.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$text of method Geocoder\\\\Query\\\\GeocodeQuery\\:\\:withText\\(\\) expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Plugin/FakeIpPlugin.php',
'path' => __DIR__.'/src/Plugin/FakeIpPlugin.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Plugin/FakeIpPlugin.php',
'path' => __DIR__.'/src/Plugin/FakeIpPlugin.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$accountId of class GeoIp2\\\\WebService\\\\Client constructor expects int, int\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/ProviderFactory/GeoIP2Factory.php',
'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$filename of class GeoIp2\\\\Database\\\\Reader constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/ProviderFactory/GeoIP2Factory.php',
'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$geoIpProvider of class Geocoder\\\\Provider\\\\GeoIP2\\\\GeoIP2Adapter constructor expects GeoIp2\\\\ProviderInterface, GeoIp2\\\\ProviderInterface\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/ProviderFactory/GeoIP2Factory.php',
'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#2 \\$licenseKey of class GeoIp2\\\\WebService\\\\Client constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/ProviderFactory/GeoIP2Factory.php',
'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
4 changes: 1 addition & 3 deletions src/DependencyInjection/BazingaGeocoderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ class BazingaGeocoderExtension extends Extension
{
/**
* @param array<mixed, mixed> $configs
*
* @return void
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$processor = new Processor();
$configuration = $this->getConfiguration($configs, $container);
Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/Compiler/AddProvidersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ class AddProvidersPass implements CompilerPassInterface
/**
* Get all providers based on their tag (`bazinga_geocoder.provider`) and
* register them.
*
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition(ProviderAggregator::class)) {
return;
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/Compiler/FactoryValidatorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ class FactoryValidatorPass implements CompilerPassInterface
*/
private static $factoryServiceIds = [];

/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
foreach (self::$factoryServiceIds as $id) {
if (!$container->hasAlias($id) && !$container->hasDefinition($id)) {
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/Compiler/ProfilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
*/
class ProfilerPass implements CompilerPassInterface
{
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition(GeocoderDataCollector::class)) {
return;
Expand Down
11 changes: 9 additions & 2 deletions src/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function isGeocodeable(object $object): bool
}

/**
* @throws MappingException
* @throws MappingException|\ReflectionException
*/
public function loadMetadataFromObject(object $object): ClassMetadata
{
Expand Down Expand Up @@ -76,6 +76,8 @@ public function loadMetadataFromObject(object $object): ClassMetadata
* @param T $object
*
* @return \ReflectionClass<T>
*
* @throws \ReflectionException
*/
private static function getReflection(object $object): \ReflectionClass
{
Expand All @@ -84,7 +86,12 @@ private static function getReflection(object $object): \ReflectionClass
return ClassUtils::newReflectionObject($object);
}

if (PHP_VERSION_ID < 80400) {
/** @var \ReflectionClass<T> */
return new \ReflectionClass(DefaultProxyClassNameResolver::getClass($object));
}

/** @var \ReflectionClass<T> */
return new \ReflectionClass(DefaultProxyClassNameResolver::getClass($object));
return new \ReflectionClass($object);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#[Entity]
#[Geocodeable]
final class DummyWithStringableGetter
class DummyWithStringableGetter
{
#[Id]
#[GeneratedValue]
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Fixtures/Entity/StringableAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Doctrine\ORM\Mapping\Embeddable;

#[Embeddable]
final class StringableAddress implements \Stringable
class StringableAddress implements \Stringable
{
public function __construct(
#[Column]
Expand Down
Loading
Loading