Skip to content

Commit

Permalink
Update rector/rector requirement from ^0.18.6 to ^1.0.3 (#154)
Browse files Browse the repository at this point in the history
* Update rector/rector requirement from ^0.18.6 to ^1.0.3

Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version.
- [Release notes](https://github.com/rectorphp/rector/releases)
- [Commits](rectorphp/rector@0.18.6...1.0.3)

---
updated-dependencies:
- dependency-name: rector/rector
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

* Migrate Rector config after 1.0 upgrade

* Re-apply Rector after upgrade

* Fix PHPStan consequent issues

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alessandro Lai <[email protected]>
  • Loading branch information
dependabot[bot] and Jean85 authored Apr 8, 2024
1 parent 0470da6 commit 909d0ee
Show file tree
Hide file tree
Showing 50 changed files with 216 additions and 294 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"phpstan/extension-installer": "1.3.1",
"jangregor/phpstan-prophecy": "1.0.1",
"phpspec/prophecy": "^1.17",
"rector/rector": "^0.18.6",
"rector/rector": "^1.0.3",
"phpspec/prophecy-phpunit": "^2.0"
},
"minimum-stability": "stable",
Expand Down
25 changes: 0 additions & 25 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Property Facile\\\\MongoDbBundle\\\\Controller\\\\ProfilerController\\:\\:\\$container \\(Symfony\\\\Component\\\\DependencyInjection\\\\Container\\) does not accept Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: src/Controller/ProfilerController.php

-
message: "#^Method Facile\\\\MongoDbBundle\\\\DataCollector\\\\MongoQuerySerializer\\:\\:prepareUnserializableData\\(\\) never returns object so it can be removed from the return type\\.$#"
count: 1
path: src/DataCollector/MongoQuerySerializer.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 7
Expand Down Expand Up @@ -50,31 +40,16 @@ parameters:
count: 1
path: src/Twig/FacileMongoDbBundleExtension.php

-
message: "#^Method Facile\\\\MongoDbBundle\\\\Tests\\\\Fixtures\\\\DataFixtures\\\\TestFixtures\\:\\:loadData\\(\\) should return array but return statement is missing\\.$#"
count: 1
path: tests/Fixtures/DataFixtures/TestFixtures.php

-
message: "#^Method Facile\\\\MongoDbBundle\\\\Tests\\\\Fixtures\\\\DataFixtures\\\\TestFixtures\\:\\:loadIndexes\\(\\) should return array but return statement is missing\\.$#"
count: 1
path: tests/Fixtures/DataFixtures/TestFixtures.php

-
message: "#^Method Facile\\\\MongoDbBundle\\\\Tests\\\\Fixtures\\\\DataFixtures\\\\TestOrderedMongoFixtures2\\:\\:loadData\\(\\) should return array but return statement is missing\\.$#"
count: 1
path: tests/Fixtures/DataFixtures/TestOrderedMongoFixtures2.php

-
message: "#^Method Facile\\\\MongoDbBundle\\\\Tests\\\\Fixtures\\\\DataFixtures\\\\TestOrderedMongoFixtures2\\:\\:loadIndexes\\(\\) should return array but return statement is missing\\.$#"
count: 1
path: tests/Fixtures/DataFixtures/TestOrderedMongoFixtures2.php

-
message: "#^Property Facile\\\\MongoDbBundle\\\\Tests\\\\Functional\\\\AppTestCase\\:\\:\\$application \\(Symfony\\\\Bundle\\\\FrameworkBundle\\\\Console\\\\Application\\) does not accept null\\.$#"
count: 1
path: tests/Functional/AppTestCase.php

-
message: "#^Access to an undefined property MongoDB\\\\Model\\\\BSONDocument\\:\\:\\$fqcn\\.$#"
count: 1
Expand Down
34 changes: 21 additions & 13 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@

use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit100\Rector\Class_\AddProphecyTraitRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Symfony\Set\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(AddProphecyTraitRector::class);

$rectorConfig->sets([
])
->withPhpSets()
->withPreparedSets(
true,
true,
false,
true
)
->withImportNames(
true,
true,
false
)
->withRules([
AddProphecyTraitRector::class,
])
->withSets([
PHPUnitSetList::PHPUNIT_90,
PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
SymfonyLevelSetList::UP_TO_SYMFONY_44
SymfonySetList::SYMFONY_44,
]);
};
6 changes: 2 additions & 4 deletions src/Capsule/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
*/
final class Client extends MongoClient
{
/** @var EventDispatcherInterface */
private $eventDispatcher;
private EventDispatcherInterface $eventDispatcher;

/** @var string */
private $clientName;
private string $clientName;

/**
* Client constructor.
Expand Down
11 changes: 4 additions & 7 deletions src/Capsule/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
*/
final class Collection extends MongoCollection
{
/** @var EventDispatcherInterface */
private $eventDispatcher;
private EventDispatcherInterface $eventDispatcher;

/** @var string */
private $clientName;
private string $clientName;

/** @var string */
private $databaseName;
private string $databaseName;

public function __construct(
Manager $manager,
Expand Down Expand Up @@ -225,7 +222,7 @@ private function translateReadPreference(ReadPreference $readPreference): string
}
}

private function notifyQueryExecution(Query $queryLog)
private function notifyQueryExecution(Query $queryLog): void
{
$queryLog->setExecutionTime(microtime(true) - $queryLog->getStart());

Expand Down
9 changes: 3 additions & 6 deletions src/Capsule/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
*/
final class Database extends MongoDatabase
{
/** @var EventDispatcherInterface */
private $eventDispatcher;
private EventDispatcherInterface $eventDispatcher;

/** @var string */
private $clientName;
private string $clientName;

/** @var string */
private $databaseName;
private string $databaseName;

/**
* Database constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ abstract class AbstractCommand extends Command
/** @var Connection */
protected $connection;

/** @var ContainerInterface */
private $container;
private ContainerInterface $container;

/**
* AbstractCommand constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Command/LoadFixturesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
class LoadFixturesCommand extends AbstractCommand
{
/** @var MongoFixturesLoader */
private $loader;
private ?MongoFixturesLoader $loader = null;

/**
* @inheritDoc
Expand Down
9 changes: 3 additions & 6 deletions src/Controller/ProfilerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,22 @@

class ProfilerController implements ContainerAwareInterface
{
/** @var Container */
private $container;
private ?ContainerInterface $container = null;

/**
* Sets the container.
*
* @param ContainerInterface|null $container A ContainerInterface instance or null
*/
public function setContainer(ContainerInterface $container = null)
public function setContainer(ContainerInterface $container = null): void
{
$this->container = $container;
}

/**
* @throws \Exception
*
* @return JsonResponse
*/
public function explainAction($token, $queryNumber)
public function explainAction(string $token, $queryNumber): JsonResponse
{
/** @var Profiler $profiler */
$profiler = $this->container->get('profiler');
Expand Down
3 changes: 1 addition & 2 deletions src/DataCollector/MongoDbDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class MongoDbDataCollector extends DataCollector

public const TIME_KEYWORD = 'totalTime';

/** @var DataCollectorLoggerInterface */
private $logger;
private ?DataCollectorLoggerInterface $logger = null;

public function __construct()
{
Expand Down
8 changes: 4 additions & 4 deletions src/DataCollector/MongoQuerySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class MongoQuerySerializer
{
public static function serialize(Query $query)
public static function serialize(Query $query): void
{
$query->setFilters(self::prepareUnserializableData($query->getFilters()));
$query->setData(self::prepareUnserializableData($query->getData()));
Expand All @@ -22,9 +22,9 @@ public static function serialize(Query $query)
/**
* @param array|object $data
*
* @return array|object
* @return mixed[]
*/
private static function prepareUnserializableData($data)
private static function prepareUnserializableData($data): array
{
if ($data instanceof Serializable) {
$data = $data->bsonSerialize();
Expand All @@ -50,7 +50,7 @@ public static function prepareItemData($item)
}

if (\is_array($item)) {
return self::prepareUnserializableData((array) $item);
return self::prepareUnserializableData($item);
}

if (\is_object($item)) {
Expand Down
20 changes: 10 additions & 10 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ public function getConfigTreeBuilder(): TreeBuilder
$treeBuilder = new TreeBuilder('mongo_db_bundle');
$rootBuilder = $treeBuilder->getRootNode();

self::addDataCollection($rootBuilder->children());
self::addClients($rootBuilder->children());
self::addConnections($rootBuilder->children());
self::addDriversOption($rootBuilder->children());
$this->addDataCollection($rootBuilder->children());
$this->addClients($rootBuilder->children());
$this->addConnections($rootBuilder->children());
$this->addDriversOption($rootBuilder->children());

return $treeBuilder;
}

private static function addDataCollection(NodeBuilder $builder): void
private function addDataCollection(NodeBuilder $builder): void
{
$builder
->booleanNode('data_collection')
->defaultTrue()
->info('Disables Data Collection if needed');
}

private static function addClients(NodeBuilder $builder): void
private function addClients(NodeBuilder $builder): void
{
$clientsBuilder = $builder
->arrayNode('clients')
Expand All @@ -49,7 +49,7 @@ private static function addClients(NodeBuilder $builder): void
->prototype('array')
->children();

self::addClientsHosts($clientsBuilder);
$this->addClientsHosts($clientsBuilder);

$clientsBuilder
->scalarNode('uri')
Expand Down Expand Up @@ -89,7 +89,7 @@ private static function addClients(NodeBuilder $builder): void
->defaultNull();
}

private static function addClientsHosts(NodeBuilder $builder): void
private function addClientsHosts(NodeBuilder $builder): void
{
$hostsBuilder = $builder
->arrayNode('hosts')
Expand All @@ -106,13 +106,13 @@ private static function addClientsHosts(NodeBuilder $builder): void
->defaultValue(27_017);
}

private static function addDriversOption(NodeBuilder $builder): void
private function addDriversOption(NodeBuilder $builder): void
{
$builder
->scalarNode('driverOptions');
}

private static function addConnections(NodeBuilder $builder): void
private function addConnections(NodeBuilder $builder): void
{
$connectionBuilder = $builder
->arrayNode('connections')
Expand Down
5 changes: 2 additions & 3 deletions src/DependencyInjection/MongoDbBundleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
*/
final class MongoDbBundleExtension extends Extension
{
/** @var ContainerBuilder */
private $containerBuilder;
private ?ContainerBuilder $containerBuilder = null;

public function load(array $configs, ContainerBuilder $container): void
{
Expand Down Expand Up @@ -76,7 +75,7 @@ private function defineConnectionFactory(): void
$this->containerBuilder->setDefinition('mongo.connection_factory', $factoryDefinition);
}

private function defineConnections(array $connections)
private function defineConnections(array $connections): void
{
foreach ($connections as $name => $conf) {
$connectionDefinition = new Definition(
Expand Down
7 changes: 3 additions & 4 deletions src/Event/Listener/DataCollectorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
*/
final class DataCollectorListener
{
/** @var DataCollectorLoggerInterface */
private $logger;
private DataCollectorLoggerInterface $logger;

public function __construct(DataCollectorLoggerInterface $logger)
{
$this->logger = $logger;
}

public function onConnectionClientCreated(ConnectionEvent $event)
public function onConnectionClientCreated(ConnectionEvent $event): void
{
$this->logger->addConnection($event->getClientName());
}

public function onQueryExecuted(QueryEvent $event)
public function onQueryExecuted(QueryEvent $event): void
{
$this->logger->logQuery($event->getQueryLog());
}
Expand Down
5 changes: 2 additions & 3 deletions src/Fixtures/AbstractContainerAwareFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@

abstract class AbstractContainerAwareFixture
{
/** @var ContainerInterface */
private $container;
private ContainerInterface $container;

protected function getContainer(): ContainerInterface
{
return $this->container;
}

public function setContainer(ContainerInterface $container)
public function setContainer(ContainerInterface $container): void
{
$this->container = $container;
}
Expand Down
Loading

0 comments on commit 909d0ee

Please sign in to comment.