Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 4 additions & 5 deletions src/DependencyInjection/BazingaGeocoderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class BazingaGeocoderExtension extends Extension
{
/**
* @param array<mixed, mixed> $configs
*
* @throws \Exception
*/
public function load(array $configs, ContainerBuilder $container): void
{
Expand Down Expand Up @@ -209,18 +211,15 @@ private function findReferences(array $options): array
foreach ($options as $key => $value) {
if (is_array($value)) {
$options[$key] = $this->findReferences($value);
} elseif ('_service' === substr((string) $key, -8) || 0 === strpos((string) $value, '@') || 'service' === $key) {
} elseif (str_ends_with((string) $key, '_service') || str_starts_with((string) $value, '@') || 'service' === $key) {
$options[$key] = new Reference(ltrim($value, '@'));
}
}

return $options;
}

/**
* @param mixed $factoryClass
*/
private function implementsProviderFactory($factoryClass): bool
private function implementsProviderFactory(mixed $factoryClass): bool
{
if (false === $interfaces = class_implements($factoryClass)) {
return false;
Expand Down
10 changes: 2 additions & 8 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ public function getConfigTreeBuilder(): TreeBuilder
return $treeBuilder;
}

/**
* @return ArrayNodeDefinition
*/
private function getProvidersNode()
private function getProvidersNode(): ArrayNodeDefinition
{
$treeBuilder = new TreeBuilder('providers');
$rootNode = $treeBuilder->getRootNode();
Expand Down Expand Up @@ -121,16 +118,13 @@ private function getProvidersNode()

/**
* Create plugin node of a client.
*
* @return ArrayNodeDefinition The plugin node
*/
private function createClientPluginNode()
private function createClientPluginNode(): ArrayNodeDefinition
{
$treeBuilder = new TreeBuilder('plugins');
$rootNode = $treeBuilder->getRootNode();
assert($rootNode instanceof ArrayNodeDefinition);

/** @var ArrayNodeDefinition $pluginList */
$pluginList = $rootNode
->info('A list of plugin service ids. The order is important.')
->arrayPrototype()
Expand Down
3 changes: 3 additions & 0 deletions src/ProviderFactory/GeoIP2Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use GeoIp2\Database\Reader;
use GeoIp2\ProviderInterface;
use GeoIp2\WebService\Client;
use MaxMind\Db\Reader\InvalidDatabaseException;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class GeoIP2Factory extends AbstractFactory
Expand All @@ -28,6 +29,8 @@ final class GeoIP2Factory extends AbstractFactory

/**
* @param array{provider: string, provider_service: ?ProviderInterface, model: string, user_id: string|int|null, license_key: string|null, locales: list<string>, webservice_options: array<string, mixed>, database_filename: ?string} $config
*
* @throws InvalidDatabaseException
*/
protected function getProvider(array $config): Provider
{
Expand Down
4 changes: 2 additions & 2 deletions src/ProviderFactory/PluginProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ final class PluginProviderFactory
{
/**
* @param Plugin[] $plugins
* @param ProviderFactoryInterface|callable $factory
* @param callable|ProviderFactoryInterface $factory
* @param array<mixed> $config config to the client factory
* @param array{max_restarts?: int<0, max>} $pluginProviderOptions config forwarded to the PluginProvider
*/
public static function createPluginProvider(array $plugins, $factory, array $config, array $pluginProviderOptions = []): PluginProvider
public static function createPluginProvider(array $plugins, callable|ProviderFactoryInterface $factory, array $config, array $pluginProviderOptions = []): PluginProvider
{
if ($factory instanceof ProviderFactoryInterface) {
$client = $factory->createProvider($config);
Expand Down
10 changes: 2 additions & 8 deletions src/Validator/Constraint/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ class Address extends Constraint
self::INVALID_ADDRESS_ERROR => 'INVALID_ADDRESS_ERROR',
];

/**
* @var string
*/
public $service = AddressValidator::class;
public string $service = AddressValidator::class;

/**
* @var string
*/
public $message = 'Address {{ address }} is not valid.';
public string $message = 'Address {{ address }} is not valid.';

/**
* @param string[]|null $options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ protected function tearDown(): void
{
$reflection = new \ReflectionObject($this->compilerPass);
$prop = $reflection->getProperty('factoryServiceIds');
if (PHP_VERSION_ID < 80100) {
$prop->setAccessible(true);
}
$prop->setValue(null, []);
}

Expand Down
34 changes: 6 additions & 28 deletions tests/Functional/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ public function testInitBundle(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}]);

$container = self::getContainer();
Expand All @@ -70,11 +67,7 @@ public function testBundleWithOneProviderConfiguration(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/simple.yml');
}]);

Expand All @@ -90,11 +83,7 @@ public function testBundleWithCachedProvider(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/cache.yml');
}]);

Expand All @@ -112,11 +101,7 @@ public function testCacheLifetimeCanBeNull(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/cache_without_lifetime.yml');
}]);

Expand All @@ -142,11 +127,7 @@ public function testBundleWithPluginsYml(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/service_plugin.yml');
}]);

Expand All @@ -164,10 +145,7 @@ public function testBundleHasRegisteredDumpers(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}]);

$container = self::getContainer();
Expand Down
36 changes: 6 additions & 30 deletions tests/Functional/GeocodeEntityListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ public function testPersistForProperty(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/listener.yml');
}]);

Expand Down Expand Up @@ -145,11 +141,7 @@ public function testPersistForGetter(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/listener.yml');
}]);

Expand Down Expand Up @@ -184,11 +176,7 @@ public function testPersistForStringableGetter(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/listener.yml');
}]);

Expand Down Expand Up @@ -223,11 +211,7 @@ public function testPersistForInvalidGetter(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/listener.yml');
}]);

Expand Down Expand Up @@ -255,11 +239,7 @@ public function testPersistForEmptyProperty(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/listener.yml');
}]);

Expand Down Expand Up @@ -287,11 +267,7 @@ public function testDoesNotGeocodeIfAddressNotChanged(): void
{
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
}

$kernel->addTestConfig(__DIR__.'/config/framework_sf'.$kernel::MAJOR_VERSION.'.yml');
$kernel->addTestConfig(__DIR__.'/config/listener.yml');
}]);

Expand Down
63 changes: 44 additions & 19 deletions tests/Functional/Helper/CacheHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,49 @@

use Psr\SimpleCache\CacheInterface;

if (PHP_VERSION_ID >= 80000) {
/**
* @internal
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class CacheHelper implements CacheInterface
{
use CacheHelperV8;
}
} else {
/**
* @internal
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class CacheHelper implements CacheInterface
{
use CacheHelperV7;
/**
* @internal
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class CacheHelper implements CacheInterface
{
public function get(string $key, mixed $default = null): mixed
{
}

public function set(string $key, mixed $value, int|\DateInterval|null $ttl = null): bool
{
return true;
}

public function delete(string $key): bool
{
return true;
}

public function clear(): bool
{
return true;
}

public function getMultiple(iterable $keys, mixed $default = null): iterable
{
return [];
}

public function setMultiple(iterable $values, int|\DateInterval|null $ttl = null): bool
{
return true;
}

public function deleteMultiple(iterable $keys): bool
{
return true;
}

public function has(string $key): bool
{
return false;
}
}
Loading