Skip to content

Feature/drop support for php 7. Modernizations #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 6 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ jobs:
fail-fast: true
matrix:
strategy: ['default']
php: ['7.3', '7.4', '8.0', '8.1']
php: ['8.0', '8.1']
include:
- php: '7.3'
- php: '8.0'
sf_version: '4.4.*'
strategy: 'lowest'
- php: '7.4'
sf_version: '5.4.*'
- php: '8.0'
sf_version: '5.4.*'
- php: '8.1'
Expand Down Expand Up @@ -104,18 +102,16 @@ jobs:
max-parallel: 10
fail-fast: true
matrix:
php: ['7.4', '8.0', '8.1']
php: ['8.0', '8.1']
include:
- php: '7.4'
- php: '8.0'
sf_version: '4.4.*'
- php: '7.4'
sf_version: '5.4.*'
- php: '8.0'
sf_version: '5.4.*'
- php: '8.1'
sf_version: '5.4.*'
- php: '8.0'
sf_version: '6.0.*'
- php: '8.1'
sf_version: '5.4.*'
- php: '8.1'
sf_version: '6.0.*'
steps:
Expand Down
4 changes: 1 addition & 3 deletions BazingaGeocoderBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ class BazingaGeocoderBundle extends Bundle
{
/**
* {@inheritdoc}
*
* @return void
*/
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

The changelog describes what have been "Added", "Changed", "Removed" or "Fixed" between versions.

## Version 6.0

### Added

- PHP 8 language features
- Typehints according to PHP 8

### Removed

- Remove MapzenFactory
- Remove GeoIPsFactory
- Remove PHP 7.x support

## Version 5.16.1

### Fixed
Expand Down
17 changes: 4 additions & 13 deletions Command/GeocodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,15 @@ class GeocodeCommand extends Command
{
protected static $defaultName = 'geocoder:geocode';

/**
* @var ProviderAggregator
*/
private $geocoder;

public function __construct(ProviderAggregator $geocoder)
public function __construct(private ProviderAggregator $geocoder)
{
$this->geocoder = $geocoder;

parent::__construct();
}

/**
* {@inheritdoc}
*
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('geocoder:geocode')
Expand All @@ -65,9 +56,9 @@ protected function configure()
/**
* {@inheritdoc}
*
* @return int
* @throws \Geocoder\Exception\Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($input->getOption('provider')) {
$this->geocoder->using($input->getOption('provider'));
Expand Down
16 changes: 4 additions & 12 deletions DataCollector/GeocoderDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ class GeocoderDataCollector extends DataCollector
/**
* @var ProfilingPlugin[]
*/
private $instances = [];
private array $instances = [];

public function __construct()
{
$this->data['queries'] = [];
$this->data['providers'] = [];
}

/**
* @return void
*/
public function reset()
public function reset(): void
{
$this->instances = [];
$this->data['queries'] = [];
Expand All @@ -47,10 +44,8 @@ public function reset()

/**
* {@inheritdoc}
*
* @return void
*/
public function collect(Request $request, Response $response, \Throwable $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null): void
{
if (!empty($this->data['queries'])) {
// To avoid collection more that once.
Expand Down Expand Up @@ -109,10 +104,7 @@ public function getProviderQueries(string $provider): array
});
}

/**
* @return void
*/
public function addInstance(ProfilingPlugin $instance)
public function addInstance(ProfilingPlugin $instance): void
{
$this->instances[] = $instance;
$this->data['providers'][] = $instance->getName();
Expand Down
19 changes: 5 additions & 14 deletions DependencyInjection/BazingaGeocoderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ class BazingaGeocoderExtension extends Extension
{
/**
* @phpstan-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 Expand Up @@ -78,10 +76,8 @@ public function load(array $configs, ContainerBuilder $container)

/**
* @phpstan-param array<mixed, mixed> $config
*
* @return void
*/
private function loadProviders(ContainerBuilder $container, array $config)
private function loadProviders(ContainerBuilder $container, array $config): void
{
foreach ($config['providers'] as $providerName => $providerConfig) {
try {
Expand Down Expand Up @@ -188,10 +184,8 @@ public function configureProviderPlugins(ContainerBuilder $container, array $con

/**
* @phpstan-param array<mixed, mixed> $config
*
* @return Configuration
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
{
/** @var bool $debug */
$debug = $container->getParameter('kernel.debug');
Expand All @@ -209,18 +203,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
4 changes: 1 addition & 3 deletions 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
13 changes: 3 additions & 10 deletions DependencyInjection/Compiler/FactoryValidatorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ class FactoryValidatorPass implements CompilerPassInterface
/**
* @var string[]
*/
private static $factoryServiceIds = [];
private static array $factoryServiceIds = [];

/**
* {@inheritdoc}
*
* @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 All @@ -42,12 +40,7 @@ public function process(ContainerBuilder $container)
}
}

/**
* @param string $factoryServiceId
*
* @return void
*/
public static function addFactoryServiceId($factoryServiceId)
public static function addFactoryServiceId(string $factoryServiceId): void
{
self::$factoryServiceIds[] = $factoryServiceId;
}
Expand Down
4 changes: 1 addition & 3 deletions DependencyInjection/Compiler/ProfilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ class ProfilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition(GeocoderDataCollector::class)) {
return;
Expand Down
23 changes: 6 additions & 17 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,18 @@ class Configuration implements ConfigurationInterface
* Whether to use the debug mode.
*
* @see https://github.com/doctrine/DoctrineBundle/blob/v1.5.2/DependencyInjection/Configuration.php#L31-L41
*
* @var bool
*/
private $debug;
private bool $debug;

/**
* @param bool $debug
*/
public function __construct($debug)
public function __construct(bool $debug)
{
$this->debug = (bool) $debug;
$this->debug = $debug;
}

/**
* Generates the configuration tree builder.
*
* @return TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('bazinga_geocoder');
$rootNode = $treeBuilder->getRootNode();
Expand Down Expand Up @@ -85,10 +78,7 @@ public function getConfigTreeBuilder()
return $treeBuilder;
}

/**
* @return ArrayNodeDefinition
*/
private function getProvidersNode()
private function getProvidersNode(): ArrayNodeDefinition
{
$treeBuilder = new TreeBuilder('providers');
$rootNode = $treeBuilder->getRootNode();
Expand Down Expand Up @@ -126,13 +116,12 @@ private function getProvidersNode()
*
* @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
Loading