Skip to content

Commit

Permalink
Drop support for symfony 3.4 (#133)
Browse files Browse the repository at this point in the history
* Drop support for symfony 3.4

* force symfony 4.4 test case

* up

* update phpstan baseline

* 6.1 deprecations

* up

* phpstan

* Reduce PHPStan baseline

* Handle 6.4 deprecations

---------

Co-authored-by: Alessandro Lai <[email protected]>
  • Loading branch information
ilario-pierbattista and Jean85 authored Jan 25, 2024
1 parent 0161ad7 commit 66ffa5a
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 85 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ jobs:
- php: 7.4
mongo-ext: 1.6.0
mongo-img: 4.2
symfony: "^4.4"
- php: 8.1
mongo-ext: 1.12.0
mongo-img: 5.0
symfony: "^5.4"
- php: 8.2
mongo-ext: 1.15.0
mongo-img: 6.0
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
* CI coverage for PHP 8.1 and 8.2
### Removed
* Removed support for PHP < 7.4
* Support for PHP < 7.4
* Support for Symfony < 4.4
* Docker images dev-dependency from https://github.com/ilario-pierbattista/docker-php-mongodb-bundle

## [1.5.0] (2022-01-06)
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"php": "^7.4 || ^8.0",
"ext-mongodb": "^1.6",
"mongodb/mongodb": "^1.5",
"symfony/framework-bundle": "^3.4 || ^4.3 || ^5.0 || ^6.0"
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "^4",
"symfony/web-profiler-bundle": "^3.4 || ^4.3 || ^5.0 || ^6.0",
"symfony/console": "^3.4 || ^4.3 || ^5.0 || ^6.0",
"symfony/web-profiler-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"phpunit/phpunit": "^9.6.13",
"symfony/phpunit-bridge": "^7.0",
"facile-it/facile-coding-standard": "^1.0.1",
Expand Down
52 changes: 1 addition & 51 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$event of method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) expects object, string given\\.$#"
count: 2
path: src/Capsule/Collection.php

-
message: "#^Parameter \\#2 \\$eventName of method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) expects string\\|null, Facile\\\\MongoDbBundle\\\\Event\\\\QueryEvent given\\.$#"
count: 2
path: src/Capsule/Collection.php

-
message: "#^Variable \\$data on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/Capsule/Collection.php

-
message: "#^Variable \\$filters on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/Capsule/Collection.php

-
message: "#^Property Facile\\\\MongoDbBundle\\\\Controller\\\\ProfilerController\\:\\:\\$container \\(Symfony\\\\Component\\\\DependencyInjection\\\\Container\\) does not accept Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
Expand All @@ -32,34 +12,9 @@ parameters:

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 3
count: 7
path: src/DependencyInjection/Configuration.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php

-
message: "#^Variable \\$data on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/Models/Query.php

-
message: "#^Variable \\$filters on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/Models/Query.php

-
message: "#^Parameter \\#1 \\$event of method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) expects object, string given\\.$#"
count: 1
path: src/Services/ClientRegistry.php

-
message: "#^Parameter \\#2 \\$eventName of method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) expects string\\|null, Facile\\\\MongoDbBundle\\\\Event\\\\ConnectionEvent given\\.$#"
count: 1
path: src/Services/ClientRegistry.php

-
message: "#^Method Facile\\\\MongoDbBundle\\\\Services\\\\Loggers\\\\DataCollectorLoggerInterface\\:\\:getConnections\\(\\) has invalid return type string\\.$#"
count: 1
Expand Down Expand Up @@ -120,11 +75,6 @@ parameters:
count: 1
path: tests/Functional/AppTestCase.php

-
message: "#^Comparison operation \"\\>\\=\" between 1 and 0 is always true\\.$#"
count: 1
path: tests/Functional/TestApp/TestKernel.php

-
message: "#^Access to an undefined property MongoDB\\\\Model\\\\BSONDocument\\:\\:\\$fqcn\\.$#"
count: 1
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ parameters:
paths:
- src/
- tests/
treatPhpDocTypesAsCertain: false
dynamicConstantNames:
- Symfony\Component\HttpKernel\Kernel::VERSION_ID
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="true"/>
</php>
<testsuites>
<testsuite name="MongoBundle Test Suite">
Expand Down
9 changes: 6 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit100\Rector\Class_\AddProphecyTraitRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\Set\SymfonyLevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
Expand All @@ -14,9 +15,11 @@
]);

// register a single rule
$rectorConfig->rule(\Rector\PHPUnit\PHPUnit100\Rector\Class_\AddProphecyTraitRector::class);
$rectorConfig->rule(AddProphecyTraitRector::class);

$rectorConfig->sets([
PHPUnitSetList::PHPUNIT_90,
PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
SymfonyLevelSetList::UP_TO_SYMFONY_44
]);
};
8 changes: 2 additions & 6 deletions src/Capsule/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,7 @@ private function prepareQuery(string $method, $filters, $data, array $options):
);

$event = new QueryEvent($query);
if (Kernel::VERSION_ID >= 40300) {
$this->eventDispatcher->dispatch($event, QueryEvent::QUERY_PREPARED);
} else {
$this->eventDispatcher->dispatch(QueryEvent::QUERY_PREPARED, $event);
}
$this->eventDispatcher->dispatch($event, QueryEvent::QUERY_PREPARED);

return $query;
}
Expand Down Expand Up @@ -238,7 +234,7 @@ private function notifyQueryExecution(Query $queryLog)
if (Kernel::VERSION_ID >= 40300) {
$this->eventDispatcher->dispatch($event, QueryEvent::QUERY_EXECUTED);
} else {
$this->eventDispatcher->dispatch(QueryEvent::QUERY_EXECUTED, $event);
$this->eventDispatcher->dispatch($event, QueryEvent::QUERY_EXECUTED);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/DropCollectionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function configure()
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$collection = $input->getArgument('collection');

Expand Down
2 changes: 1 addition & 1 deletion src/Command/DropDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function configure()
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->io->writeln(sprintf('Dropping database %s', $this->connection->getDatabaseName()));
$this->connection->drop();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/LoadFixturesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->io->writeln('Loading mongo fixtures');
/** @var Application $application */
Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ final class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('mongo_db_bundle');
$rootBuilder = \method_exists(TreeBuilder::class, 'getRootNode')
? $treeBuilder->getRootNode()
: $treeBuilder->root('mongo_db_bundle');
$rootBuilder = $treeBuilder->getRootNode();

self::addDataCollection($rootBuilder->children());
self::addClients($rootBuilder->children());
Expand Down
1 change: 0 additions & 1 deletion src/Fixtures/FixtureSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ private static function orderedFixtureSorter(): \Closure
return $a->getOrder() - $b->getOrder();
}

/* @phpstan-ignore-next-line phpstan, you're wrong */
if ($a instanceof OrderedFixtureInterface && ! $b instanceof OrderedFixtureInterface) {
return 1;
}
Expand Down
7 changes: 1 addition & 6 deletions src/Services/ClientRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Facile\MongoDbBundle\Services\DriverOptions\DriverOptionsInterface;
use MongoDB\Client;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Kernel;

/**
* Class ClientRegistry.
Expand Down Expand Up @@ -116,11 +115,7 @@ public function getClient(string $name, ?string $databaseName = null): Client
$this->clients[$clientKey] = $this->buildClient($name, $conf->getUri(), $options, $conf->getDriverOptions());

$event = new ConnectionEvent($clientKey);
if (Kernel::VERSION_ID >= 40300) {
$this->eventDispatcher->dispatch($event, ConnectionEvent::CLIENT_CREATED);
} else {
$this->eventDispatcher->dispatch(ConnectionEvent::CLIENT_CREATED, $event);
}
$this->eventDispatcher->dispatch($event, ConnectionEvent::CLIENT_CREATED);
}

return $this->clients[$clientKey];
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Command/AbstractCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function configure()
->setDescription('fake test command');
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->io->writeln('Executed');

Expand Down
8 changes: 6 additions & 2 deletions tests/Functional/TestApp/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$suffix = '_docker';
}

if (version_compare(Kernel::VERSION, '3.2.0') >= 0) {
$version = '_32';
if (version_compare(Kernel::VERSION, '6.1.0') >= 0) {
$version = '_61';
}

if (version_compare(Kernel::VERSION, '6.4.0') >= 0) {
$version = '_64';
}

$configFile = sprintf('/config_test%s%s.yml', $version, $suffix);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
framework:
secret: "Four can keep a secret, if three of them are dead."
annotations:
enabled: false
http_method_override: true

mongo_db_bundle:
clients:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
framework:
secret: "Four can keep a secret, if three of them are dead."
annotations:
enabled: false
http_method_override: true

mongo_db_bundle:
clients:
Expand Down
7 changes: 7 additions & 0 deletions tests/Functional/TestApp/config_test_64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
imports:
- { resource: ./config_test_61.yml }

framework:
handle_all_throwables: true
php_errors:
log: true
6 changes: 6 additions & 0 deletions tests/Functional/TestApp/config_test_64_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
imports:
- { resource: ./config_test_61_docker.yml }

framework:
handle_all_throwables: true
php_errors: true

0 comments on commit 66ffa5a

Please sign in to comment.