Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
composer-options: "--optimize-autoloader"

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

phpunit:
name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }})
Expand Down
3 changes: 2 additions & 1 deletion .php-cs-fixer.php → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
;

return (new PhpCsFixer\Config())
->setFinder($finder)
->setUnsupportedPhpVersionAllowed(true)
->setRules([
'@Symfony' => true,
'no_superfluous_phpdoc_tags' => false,
'phpdoc_to_comment' => ['ignored_tags' => ['var']], // phpstan errors pops up without this
])
->setFinder($finder)
;
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"require-dev": {
"doctrine/doctrine-bundle": "^2.18 || ^3.0",
"doctrine/orm": "^2.20 || ^3.0",
"fakerphp/faker": "^1.24",
"friendsofphp/php-cs-fixer": "^3.92",
"fakerphp/faker": "^1.24.1",
"friendsofphp/php-cs-fixer": "^3.92.4",
"geocoder-php/algolia-places-provider": "^0.5",
"geocoder-php/arcgis-online-provider": "^4.5",
"geocoder-php/bing-maps-provider": "^4.4",
Expand All @@ -53,11 +53,11 @@
"geocoder-php/pickpoint-provider": "^4.4",
"geocoder-php/tomtom-provider": "^4.5",
"geocoder-php/yandex-provider": "^4.6",
"nyholm/nsa": "^1.3",
"nyholm/psr7": "^1.8",
"nyholm/nsa": "^1.3.1",
"nyholm/psr7": "^1.8.2",
"nyholm/symfony-bundle-test": "^3.1",
"phpstan/phpstan": "^2.1",
"psr/http-client": "^1.0",
"phpstan/phpstan": "^2.1.33",
"psr/http-client": "^1.0.3",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"symfony/cache": "^6.4 || ^7.0 || ^8.0",
"symfony/config": "^6.4 || ^7.0 || ^8.0",
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/AddProvidersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* @author William Durand <[email protected]>
*/
class AddProvidersPass implements CompilerPassInterface
final class AddProvidersPass implements CompilerPassInterface
{
/**
* Get all providers based on their tag (`bazinga_geocoder.provider`) and
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/FactoryValidatorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Tobias Nyholm <[email protected]>
*/
class FactoryValidatorPass implements CompilerPassInterface
final class FactoryValidatorPass implements CompilerPassInterface
{
/**
* @var list<non-empty-string>
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/ProfilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author Tobias Nyholm <[email protected]>
*/
class ProfilerPass implements CompilerPassInterface
final class ProfilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
Expand Down
7 changes: 4 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Bazinga\GeocoderBundle\DependencyInjection;

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->addDefaultsIfNotSet()
->treatFalseLike(['enabled' => false])
->treatTrueLike(['enabled' => true])
->treatNullLike(['enabled' => $this->debug])
->treatNullLike(['enabled' => \class_exists(DoctrineBundle::class)])
->info('Extend the debug profiler with information about requests.')
->children()
->booleanNode('enabled')
Expand All @@ -54,7 +55,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->arrayNode('fake_ip')
->beforeNormalization()
->ifString()
->then(function ($value) {
->then(function (string $value): array {
return ['ip' => $value];
})
->end()
Expand Down Expand Up @@ -132,7 +133,7 @@ private function createClientPluginNode(): ArrayNodeDefinition
$pluginList
// support having just a service id in the list
->beforeNormalization()
->always(function ($plugin) {
->always(function (array|string $plugin) {
if (is_string($plugin)) {
return [
'reference' => [
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/ProfilingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public function handleQuery(Query $query, callable $next, callable $first): Prom
{
$startTime = microtime(true);

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

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

Expand Down
2 changes: 1 addition & 1 deletion tests/Command/GeocodeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
final class GeocodeCommandTest extends TestCase
{
private static $address = '10 rue Gambetta, Paris, France';
private static string $address = '10 rue Gambetta, Paris, France';

public function testExecute(): void
{
Expand Down
2 changes: 2 additions & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class ConfigurationTest extends TestCase
public function testGetConfigTreeBuilder(): void
{
$config = Yaml::parseFile(__DIR__.'/Fixtures/config.yml');
self::assertIsArray($config);

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

$configuration = new Configuration(false);
$treeBuilder = $configuration->getConfigTreeBuilder();
Expand Down
13 changes: 8 additions & 5 deletions tests/Functional/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use Nyholm\BundleTest\TestKernel;
use Nyholm\NSA;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpKernel\KernelInterface;

final class BundleInitializationTest extends KernelTestCase
{
Expand All @@ -36,11 +35,12 @@ protected static function getKernelClass(): string
return TestKernel::class;
}

protected static function createKernel(array $options = []): KernelInterface
/**
* @param array<mixed> $options
*/
protected static function createKernel(array $options = []): TestKernel
{
/**
* @var TestKernel $kernel
*/
/** @var TestKernel $kernel */
$kernel = parent::createKernel($options);
$kernel->addTestBundle(BazingaGeocoderBundle::class);
$kernel->handleOptions($options);
Expand Down Expand Up @@ -93,6 +93,7 @@ public function testBundleWithCachedProvider(): void
$service = $container->get('bazinga_geocoder.provider.acme');
self::assertInstanceOf(PluginProvider::class, $service);
$plugins = NSA::getProperty($service, 'plugins');
self::assertIsArray($plugins);
self::assertNotEmpty($plugins);
self::assertInstanceOf(CachePlugin::class, $plugins[0]);
}
Expand All @@ -114,6 +115,7 @@ public function testCacheLifetimeCanBeNull(): void
self::assertInstanceOf(PluginProvider::class, $service);

$plugins = NSA::getProperty($service, 'plugins');
self::assertIsArray($plugins);
self::assertCount(1, $plugins);

$cachePlugin = array_shift($plugins);
Expand All @@ -137,6 +139,7 @@ public function testBundleWithPluginsYml(): void
$service = $container->get('bazinga_geocoder.provider.acme');
self::assertInstanceOf(PluginProvider::class, $service);
$plugins = NSA::getProperty($service, 'plugins');
self::assertIsArray($plugins);
self::assertCount(3, $plugins);
self::assertInstanceOf(LoggerPlugin::class, $plugins[0]);
}
Expand Down
12 changes: 3 additions & 9 deletions tests/Functional/CustomTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
class CustomTestKernel extends TestKernel implements CompilerPassInterface
{
private $warmupDir;
private ?string $warmupDir = null;

public function reboot(?string $warmupDir): void
{
Expand All @@ -54,6 +54,8 @@ public function getShareDir(): ?string

/**
* Returns the kernel parameters.
*
* @return array<string, mixed>
*/
protected function getKernelParameters(): array
{
Expand Down Expand Up @@ -87,14 +89,6 @@ protected function getKernelParameters(): array
] + (null !== ($dir = $this->getShareDir()) ? ['kernel.share_dir' => realpath($dir) ?: $dir] : []);
}

/**
* @internal
*/
public function setAnnotatedClassCache(array $annotatedClasses): void
{
file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('<?php return %s;', var_export($annotatedClasses, true)));
}

// Can be removed after dropping Symfony 5.4
public function process(ContainerBuilder $container): void
{
Expand Down
14 changes: 7 additions & 7 deletions tests/Functional/Fixtures/Entity/DummyWithEmptyProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ class DummyWithEmptyProperty
#[Id]
#[GeneratedValue]
#[Column(type: Types::INTEGER)]
public $id;
public ?int $id = null;

#[Column(nullable: true)]
#[Column(type: Types::FLOAT, nullable: true)]
#[Latitude]
public $latitude;
public ?float $latitude = null;

#[Column(nullable: true)]
#[Column(type: Types::FLOAT, nullable: true)]
#[Longitude]
public $longitude;
public ?float $longitude = null;

#[Column]
#[Column(type: Types::STRING)]
#[Address]
public $address;
public ?string $address = null;
}
31 changes: 18 additions & 13 deletions tests/Functional/Fixtures/Entity/DummyWithGetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,51 @@ class DummyWithGetter
#[Id]
#[GeneratedValue]
#[Column(type: Types::INTEGER)]
private $id;
private ?int $id = null;

#[Column]
#[Column(type: Types::FLOAT)]
#[Latitude]
private $latitude;
private ?float $latitude = null;

#[Column]
#[Column(type: Types::FLOAT)]
#[Longitude]
private $longitude;
private ?float $longitude = null;

#[Column]
private $_address;
#[Column(type: Types::STRING)]
private ?string $_address = null;

public function setAddress($address): void
public function getId(): ?int
{
return $this->id;
}

public function setAddress(string $address): void
{
$this->_address = $address;
}

#[Address]
public function getAddress()
public function getAddress(): ?string
{
return $this->_address;
}

public function getLatitude()
public function getLatitude(): ?float
{
return $this->latitude;
}

public function setLatitude($latitude): void
public function setLatitude(float $latitude): void
{
$this->latitude = $latitude;
}

public function getLongitude()
public function getLongitude(): ?float
{
return $this->longitude;
}

public function setLongitude($longitude): void
public function setLongitude(float $longitude): void
{
$this->longitude = $longitude;
}
Expand Down
31 changes: 18 additions & 13 deletions tests/Functional/Fixtures/Entity/DummyWithInvalidGetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,51 @@ class DummyWithInvalidGetter
#[Id]
#[GeneratedValue]
#[Column(type: Types::INTEGER)]
private $id;
private ?int $id = null;

#[Column]
#[Column(type: Types::FLOAT)]
#[Latitude]
private $latitude;
private ?float $latitude = null;

#[Column]
#[Column(type: Types::FLOAT)]
#[Longitude]
private $longitude;
private ?float $longitude = null;

#[Column]
private $_address;
#[Column(type: Types::STRING)]
private ?string $_address = null;

public function setAddress($address): void
public function getId(): ?int
{
return $this->id;
}

public function setAddress(string $address): void
{
$this->_address = $address;
}

#[Address]
public function getAddress($requiredParameter)
public function getAddress(mixed $requiredParameter): ?string
{
return $this->_address;
}

public function getLatitude()
public function getLatitude(): ?float
{
return $this->latitude;
}

public function setLatitude($latitude): void
public function setLatitude(float $latitude): void
{
$this->latitude = $latitude;
}

public function getLongitude()
public function getLongitude(): ?float
{
return $this->longitude;
}

public function setLongitude($longitude): void
public function setLongitude(float $longitude): void
{
$this->longitude = $longitude;
}
Expand Down
Loading