Skip to content

Commit c463452

Browse files
authored
Merge pull request #395 from norkunas/batch
Fix some phpstan warnings
2 parents 7474234 + 48c1f32 commit c463452

29 files changed

+160
-187
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
composer-options: "--optimize-autoloader"
5353

5454
- name: "Run PHP-CS-Fixer"
55-
run: vendor/bin/php-cs-fixer fix -v --dry-run --allow-unsupported-php-version=yes --using-cache=no --format=checkstyle | cs2pr
55+
run: vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no --format=checkstyle | cs2pr
5656

5757
phpunit:
5858
name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }})
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
;
88

99
return (new PhpCsFixer\Config())
10+
->setFinder($finder)
11+
->setUnsupportedPhpVersionAllowed(true)
1012
->setRules([
1113
'@Symfony' => true,
1214
'no_superfluous_phpdoc_tags' => false,
1315
'phpdoc_to_comment' => ['ignored_tags' => ['var']], // phpstan errors pops up without this
1416
])
15-
->setFinder($finder)
1617
;

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"require-dev": {
2626
"doctrine/doctrine-bundle": "^2.18 || ^3.0",
2727
"doctrine/orm": "^2.20 || ^3.0",
28-
"fakerphp/faker": "^1.24",
29-
"friendsofphp/php-cs-fixer": "^3.92",
28+
"fakerphp/faker": "^1.24.1",
29+
"friendsofphp/php-cs-fixer": "^3.92.4",
3030
"geocoder-php/algolia-places-provider": "^0.5",
3131
"geocoder-php/arcgis-online-provider": "^4.5",
3232
"geocoder-php/bing-maps-provider": "^4.4",
@@ -53,11 +53,11 @@
5353
"geocoder-php/pickpoint-provider": "^4.4",
5454
"geocoder-php/tomtom-provider": "^4.5",
5555
"geocoder-php/yandex-provider": "^4.6",
56-
"nyholm/nsa": "^1.3",
57-
"nyholm/psr7": "^1.8",
56+
"nyholm/nsa": "^1.3.1",
57+
"nyholm/psr7": "^1.8.2",
5858
"nyholm/symfony-bundle-test": "^3.1",
59-
"phpstan/phpstan": "^2.1",
60-
"psr/http-client": "^1.0",
59+
"phpstan/phpstan": "^2.1.33",
60+
"psr/http-client": "^1.0.3",
6161
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
6262
"symfony/cache": "^6.4 || ^7.0 || ^8.0",
6363
"symfony/config": "^6.4 || ^7.0 || ^8.0",

src/DependencyInjection/Compiler/AddProvidersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* @author William Durand <william.durand1@gmail.com>
2222
*/
23-
class AddProvidersPass implements CompilerPassInterface
23+
final class AddProvidersPass implements CompilerPassInterface
2424
{
2525
/**
2626
* Get all providers based on their tag (`bazinga_geocoder.provider`) and

src/DependencyInjection/Compiler/FactoryValidatorPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
2323
*/
24-
class FactoryValidatorPass implements CompilerPassInterface
24+
final class FactoryValidatorPass implements CompilerPassInterface
2525
{
2626
/**
2727
* @var list<non-empty-string>

src/DependencyInjection/Compiler/ProfilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
2424
*/
25-
class ProfilerPass implements CompilerPassInterface
25+
final class ProfilerPass implements CompilerPassInterface
2626
{
2727
public function process(ContainerBuilder $container): void
2828
{

src/DependencyInjection/Configuration.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Bazinga\GeocoderBundle\DependencyInjection;
1414

15+
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
1516
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1617
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1718
use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -42,7 +43,7 @@ public function getConfigTreeBuilder(): TreeBuilder
4243
->addDefaultsIfNotSet()
4344
->treatFalseLike(['enabled' => false])
4445
->treatTrueLike(['enabled' => true])
45-
->treatNullLike(['enabled' => $this->debug])
46+
->treatNullLike(['enabled' => \class_exists(DoctrineBundle::class)])
4647
->info('Extend the debug profiler with information about requests.')
4748
->children()
4849
->booleanNode('enabled')
@@ -54,7 +55,7 @@ public function getConfigTreeBuilder(): TreeBuilder
5455
->arrayNode('fake_ip')
5556
->beforeNormalization()
5657
->ifString()
57-
->then(function ($value) {
58+
->then(function (string $value): array {
5859
return ['ip' => $value];
5960
})
6061
->end()
@@ -132,7 +133,7 @@ private function createClientPluginNode(): ArrayNodeDefinition
132133
$pluginList
133134
// support having just a service id in the list
134135
->beforeNormalization()
135-
->always(function ($plugin) {
136+
->always(function (array|string $plugin) {
136137
if (is_string($plugin)) {
137138
return [
138139
'reference' => [

src/Plugin/ProfilingPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function handleQuery(Query $query, callable $next, callable $first): Prom
4343
{
4444
$startTime = microtime(true);
4545

46-
return $next($query)->then(function (Collection $result) use ($query, $startTime) {
46+
return $next($query)->then(function (Collection $result) use ($query, $startTime): Collection {
4747
$duration = (microtime(true) - $startTime) * 1000;
4848
$this->logQuery($query, $duration, $result);
4949

5050
return $result;
51-
}, function (Exception $exception) use ($query, $startTime) {
51+
}, function (Exception $exception) use ($query, $startTime): void {
5252
$duration = (microtime(true) - $startTime) * 1000;
5353
$this->logQuery($query, $duration, $exception);
5454

tests/Command/GeocodeCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
final class GeocodeCommandTest extends TestCase
3232
{
33-
private static $address = '10 rue Gambetta, Paris, France';
33+
private static string $address = '10 rue Gambetta, Paris, France';
3434

3535
public function testExecute(): void
3636
{

tests/DependencyInjection/ConfigurationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class ConfigurationTest extends TestCase
2525
public function testGetConfigTreeBuilder(): void
2626
{
2727
$config = Yaml::parseFile(__DIR__.'/Fixtures/config.yml');
28+
self::assertIsArray($config);
2829

2930
$configuration = new Configuration(true);
3031
$treeBuilder = $configuration->getConfigTreeBuilder();
@@ -41,6 +42,7 @@ public function testGetConfigTreeBuilder(): void
4142
public function testGetConfigTreeBuilderNoDebug(): void
4243
{
4344
$config = Yaml::parseFile(__DIR__.'/Fixtures/config.yml');
45+
self::assertIsArray($config);
4446

4547
$configuration = new Configuration(false);
4648
$treeBuilder = $configuration->getConfigTreeBuilder();

0 commit comments

Comments
 (0)