diff --git a/rector.php b/rector.php index 84446e11d..7e6d72f48 100644 --- a/rector.php +++ b/rector.php @@ -17,6 +17,7 @@ use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; +use Rector\Php81\Rector\Array_\FirstClassCallableRector; use Rector\Php81\Rector\ClassMethod\NewInInitializerRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; @@ -104,6 +105,10 @@ // used by Configurator __DIR__ . '/src/Scaffolder/src/Command', ], + + FirstClassCallableRector::class => [ + __DIR__ . '/src/Core/tests/Scope/UseCaseTest.php', + ], ]) ->withPhpSets(php81: true) ->withPreparedSets(deadCode: true) diff --git a/src/Core/tests/Scope/UseCaseTest.php b/src/Core/tests/Scope/UseCaseTest.php index 51ce07bc2..fcafabd7b 100644 --- a/src/Core/tests/Scope/UseCaseTest.php +++ b/src/Core/tests/Scope/UseCaseTest.php @@ -79,7 +79,7 @@ public function testScopeBindingsAsNotSingletons(bool $theSame, string $alias, m public static function provideScopeBindingsAsNotSingletons(): iterable { - yield 'array-factory' => [false, 'foo', (new Factory())->makeStdClass(...)]; + yield 'array-factory' => [false, 'foo', [Factory::class, 'makeStdClass']]; yield 'class-name' => [false, SampleClass::class, SampleClass::class]; yield 'object' => [true, stdClass::class, new stdClass()]; } @@ -107,11 +107,11 @@ public function testScopeDefinition(): void self::assertNotSame($c1, $c2); self::assertInstanceOf(stdClass::class, $obj2); self::assertNotSame($obj1, $obj2); - }, bindings: ['foo' => (new Factory())->makeStdClass(...)]); + }, bindings: ['foo' => [Factory::class, 'makeStdClass']]); // $obj2 should be garbage collected self::assertCount(1, $this->weakMap); - }, bindings: ['foo' => (new Factory())->makeStdClass(...)]); + }, bindings: ['foo' => [Factory::class, 'makeStdClass']]); // $obj1 should be garbage collected self::assertEmpty($this->weakMap); @@ -125,7 +125,7 @@ public function testScopeDefinition(): void public function testChildContainerResolvesDepsFromParent(): void { $root = new Container(); - $root->bindSingleton('bar', (new Factory())->makeStdClass(...)); + $root->bindSingleton('bar', [Factory::class, 'makeStdClass']); $root->bind(stdClass::class, new stdClass()); $root->runScoped(function (ContainerInterface $c1) use ($root) { @@ -149,7 +149,7 @@ public function testChildContainerResolvesDepsFromParent(): void "Nested container mustn't create new instance using class name as key without definition." ); }); - }, bindings: ['foo' => (new Factory())->makeStdClass(...)]); + }, bindings: ['foo' => [Factory::class, 'makeStdClass']]); } /**