Skip to content

Commit 2127237

Browse files
authored
Adding PHP7 syntax (#160)
* Adding PHP7 syntax * Fixed tests
1 parent e164d95 commit 2127237

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+174
-34
lines changed

BazingaGeocoderBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE

Command/GeocodeCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE
@@ -80,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8082
}
8183
}
8284

83-
private function humanize($text)
85+
private function humanize(string $text): string
8486
{
8587
$text = preg_replace('/([A-Z][a-z]+)|([A-Z][A-Z]+)|([^A-Za-z ]+)/', ' \1', $text);
8688

DataCollector/GeocoderDataCollector.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE
@@ -64,7 +66,7 @@ public function getQueries(): array
6466
*
6567
* @return float
6668
*/
67-
public function getTotalDuration()
69+
public function getTotalDuration(): float
6870
{
6971
$time = 0;
7072
foreach ($this->data['queries'] as $command) {
@@ -87,7 +89,7 @@ public function getProviders(): array
8789
*
8890
* @return array
8991
*/
90-
public function getProviderQueries($provider): array
92+
public function getProviderQueries(string $provider): array
9193
{
9294
return array_filter($this->data['queries'], function ($data) use ($provider) {
9395
return $data['providerName'] === $provider;
@@ -106,7 +108,7 @@ public function addInstance(ProfilingPlugin $instance)
106108
/**
107109
* {@inheritdoc}
108110
*/
109-
public function getName()
111+
public function getName(): string
110112
{
111113
return 'geocoder';
112114
}

DependencyInjection/BazingaGeocoderExtension.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE
@@ -61,7 +63,7 @@ private function loadProviders(ContainerBuilder $container, array $config)
6163
foreach ($config['providers'] as $providerName => $providerConfig) {
6264
$factoryService = $container->getDefinition($providerConfig['factory']);
6365
$factoryClass = $factoryService->getClass() ?: $providerConfig['factory'];
64-
if (!class_implements($factoryClass, ProviderFactoryInterface::class)) {
66+
if (!$this->implementsPoviderFactory($factoryClass)) {
6567
throw new \LogicException(sprintf('Provider factory "%s" must implement ProviderFactoryInterface', $providerConfig['factory']));
6668
}
6769
$factoryClass::validate($providerConfig['options'], $providerName);
@@ -198,16 +200,30 @@ public function getConfiguration(array $config, ContainerBuilder $container)
198200
*
199201
* @return array
200202
*/
201-
private function findReferences(array $options)
203+
private function findReferences(array $options): array
202204
{
203205
foreach ($options as $key => $value) {
204206
if (is_array($value)) {
205207
$options[$key] = $this->findReferences($value);
206-
} elseif (substr($key, -8) === '_service' || strpos($value, '@') === 0 || $key === 'service') {
208+
} elseif (substr((string) $key, -8) === '_service' || strpos((string) $value, '@') === 0 || $key === 'service') {
207209
$options[$key] = new Reference(ltrim($value, '@'));
208210
}
209211
}
210212

211213
return $options;
212214
}
215+
216+
/**
217+
* @param mixed $factoryClass
218+
*
219+
* @return bool
220+
*/
221+
private function implementsPoviderFactory($factoryClass): bool
222+
{
223+
if (false === $interfaces = class_implements($factoryClass)) {
224+
return false;
225+
}
226+
227+
return in_array(ProviderFactoryInterface::class, $interfaces);
228+
}
213229
}

DependencyInjection/Compiler/AddProvidersPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE

DependencyInjection/Compiler/ProfilerPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE

DependencyInjection/Configuration.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE

Doctrine/ORM/GeocoderListener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE

Mapping/Annotations/Address.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE

Mapping/Annotations/Geocodeable.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the BazingaGeocoderBundle package.
57
* For the full copyright and license information, please view the LICENSE

0 commit comments

Comments
 (0)