diff --git a/src/ProxyManager/Configuration.php b/src/ProxyManager/Configuration.php index 136c42ad2..35d698c98 100644 --- a/src/ProxyManager/Configuration.php +++ b/src/ProxyManager/Configuration.php @@ -27,14 +27,14 @@ class Configuration { public const DEFAULT_PROXY_NAMESPACE = 'ProxyManagerGeneratedProxy'; - protected ?string $proxiesTargetDir; - protected string $proxiesNamespace = self::DEFAULT_PROXY_NAMESPACE; - protected ?GeneratorStrategyInterface $generatorStrategy; - protected ?AutoloaderInterface $proxyAutoloader; - protected ?ClassNameInflectorInterface $classNameInflector; - protected ?SignatureGeneratorInterface $signatureGenerator; - protected ?SignatureCheckerInterface $signatureChecker; - protected ?ClassSignatureGeneratorInterface $classSignatureGenerator; + protected ?string $proxiesTargetDir = null; + protected string $proxiesNamespace = self::DEFAULT_PROXY_NAMESPACE; + protected ?GeneratorStrategyInterface $generatorStrategy = null; + protected ?AutoloaderInterface $proxyAutoloader = null; + protected ?ClassNameInflectorInterface $classNameInflector = null; + protected ?SignatureGeneratorInterface $signatureGenerator = null; + protected ?SignatureCheckerInterface $signatureChecker = null; + protected ?ClassSignatureGeneratorInterface $classSignatureGenerator = null; public function setProxyAutoloader(AutoloaderInterface $proxyAutoloader): void { diff --git a/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php b/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php index bf0818b86..6188f7939 100644 --- a/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php @@ -86,7 +86,7 @@ protected function setUp(): void $this ->classNameInflector ->method('getUserClassName') - ->willReturn('stdClass'); + ->willReturn(stdClass::class); $this->factory = $this->getMockForAbstractClass(AbstractBaseFactory::class, [$configuration]); @@ -103,7 +103,7 @@ public function testGeneratesClass(): void $this ->classNameInflector ->method('getProxyClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn($generatedClass); $this @@ -129,9 +129,7 @@ public function testGeneratesClass(): void ->expects(self::once()) ->method('generate') ->with( - self::callback(static function (ReflectionClass $reflectionClass): bool { - return $reflectionClass->getName() === stdClass::class; - }), + self::callback(static fn (ReflectionClass $reflectionClass): bool => $reflectionClass->getName() === stdClass::class), self::isInstanceOf(ClassGenerator::class), ['some' => 'proxy', 'options' => 'here'] ); diff --git a/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php b/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php index 2a90a0e83..06222acf0 100644 --- a/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php @@ -94,7 +94,7 @@ public function testWillSkipAutoGeneration(): void ->inflector ->expects(self::once()) ->method('getProxyClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn(AccessInterceptorValueHolderMock::class); $factory = new AccessInterceptorScopeLocalizerFactory($this->config); @@ -140,9 +140,7 @@ public function testWillTryAutoGeneration(): void ->method('generate') ->with( self::callback( - static function (ClassGenerator $targetClass) use ($proxyClassName): bool { - return $targetClass->getName() === $proxyClassName; - } + static fn (ClassGenerator $targetClass): bool => $targetClass->getName() === $proxyClassName ) ); @@ -164,14 +162,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName): bool { ->inflector ->expects(self::once()) ->method('getProxyClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn(LazyLoadingMock::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); diff --git a/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php b/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php index 7fafd018f..35e9efd77 100644 --- a/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php @@ -90,7 +90,7 @@ public function testWillSkipAutoGeneration(): void ->inflector ->expects(self::once()) ->method('getProxyClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn(AccessInterceptorValueHolderMock::class); $factory = new AccessInterceptorValueHolderFactory($this->config); @@ -135,9 +135,7 @@ public function testWillTryAutoGeneration(): void ->method('generate') ->with( self::callback( - static function (ClassGenerator $targetClass) use ($proxyClassName): bool { - return $targetClass->getName() === $proxyClassName; - } + static fn (ClassGenerator $targetClass): bool => $targetClass->getName() === $proxyClassName ) ); @@ -159,14 +157,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName): bool { ->inflector ->expects(self::once()) ->method('getProxyClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn(EmptyClass::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); diff --git a/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php b/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php index f19da0f47..e363761b3 100644 --- a/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php @@ -91,9 +91,7 @@ public function testWillSkipAutoGeneration(): void ->willReturn(LazyLoadingMock::class); $factory = new LazyLoadingGhostFactory($this->config); - $initializer = static function (): bool { - return true; - }; + $initializer = static fn (): bool => true; $proxy = $factory->createProxy($className, $initializer); self::assertSame($initializer, $proxy->getProxyInitializer()); @@ -123,9 +121,7 @@ public function testWillTryAutoGeneration(): void ->method('generate') ->with( self::callback( - static function (ClassGenerator $targetClass) use ($proxyClassName): bool { - return $targetClass->getName() === $proxyClassName; - } + static fn (ClassGenerator $targetClass): bool => $targetClass->getName() === $proxyClassName ) ); @@ -158,9 +154,7 @@ static function (ClassGenerator $targetClass) use ($proxyClassName): bool { $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); $factory = new LazyLoadingGhostFactory($this->config); - $initializer = static function (): bool { - return true; - }; + $initializer = static fn (): bool => true; $proxy = $factory->createProxy($className, $initializer); self::assertSame($initializer, $proxy->getProxyInitializer()); diff --git a/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php b/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php index 39698df69..c5d311a3a 100644 --- a/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php @@ -92,9 +92,7 @@ public function testWillSkipAutoGeneration(): void ->willReturn(LazyLoadingMock::class); $factory = new LazyLoadingValueHolderFactory($this->config); - $initializer = static function (): bool { - return true; - }; + $initializer = static fn (): bool => true; $proxy = $factory->createProxy($className, $initializer); self::assertSame($initializer, $proxy->getProxyInitializer()); @@ -124,9 +122,7 @@ public function testWillTryAutoGeneration(): void ->method('generate') ->with( self::callback( - static function (ClassGenerator $targetClass) use ($proxyClassName): bool { - return $targetClass->getName() === $proxyClassName; - } + static fn (ClassGenerator $targetClass): bool => $targetClass->getName() === $proxyClassName ) ); @@ -159,9 +155,7 @@ static function (ClassGenerator $targetClass) use ($proxyClassName): bool { $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); $factory = new LazyLoadingValueHolderFactory($this->config); - $initializer = static function (): bool { - return true; - }; + $initializer = static fn (): bool => true; $proxy = $factory->createProxy($className, $initializer); self::assertInstanceOf($proxyClassName, $proxy); diff --git a/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php b/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php index fa04c3592..4d83dc9b9 100644 --- a/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php @@ -75,7 +75,7 @@ public function testWillSkipAutoGeneration(): void ->inflector ->expects(self::once()) ->method('getProxyClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn(NullObjectMock::class); (new NullObjectFactory($this->config))->createProxy($instance); @@ -105,9 +105,7 @@ public function testWillTryAutoGeneration(): void ->method('generate') ->with( self::callback( - static function (ClassGenerator $targetClass) use ($proxyClassName): bool { - return $targetClass->getName() === $proxyClassName; - } + static fn (ClassGenerator $targetClass): bool => $targetClass->getName() === $proxyClassName ) ); @@ -126,14 +124,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName): bool { ->inflector ->expects(self::once()) ->method('getProxyClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') - ->with('stdClass') + ->with(stdClass::class) ->willReturn(NullObjectMock::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); diff --git a/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php b/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php index b82652109..473dfb544 100644 --- a/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php @@ -18,6 +18,7 @@ use ProxyManager\Signature\SignatureCheckerInterface; use ProxyManagerTestAsset\BaseInterface; use ProxyManagerTestAsset\RemoteProxy\RemoteObjectMock; +use stdClass; /** * @covers \ProxyManager\Factory\AbstractBaseFactory @@ -97,9 +98,7 @@ public function testWillTryAutoGeneration(): void ->method('generate') ->with( self::callback( - static function (ClassGenerator $targetClass) use ($proxyClassName): bool { - return $targetClass->getName() === $proxyClassName; - } + static fn (ClassGenerator $targetClass): bool => $targetClass->getName() === $proxyClassName ) ); @@ -130,7 +129,7 @@ static function (ClassGenerator $targetClass) use ($proxyClassName): bool { ->expects(self::once()) ->method('getUserClassName') ->with(BaseInterface::class) - ->willReturn('stdClass'); + ->willReturn(stdClass::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); diff --git a/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php b/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php index 585fd2210..7eefe2f76 100644 --- a/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php @@ -29,7 +29,6 @@ use stdClass; use function array_values; -use function get_class; use function random_int; use function serialize; use function uniqid; @@ -333,10 +332,8 @@ public function testWillBehaveLikeObjectWithNormalConstructor(): void self::assertSame(13, $instance->amount, 'Verifying that test asset works as expected'); self::assertSame(13, $instance->getAmount(), 'Verifying that test asset works as expected'); - $proxyName = get_class( - (new AccessInterceptorScopeLocalizerFactory()) - ->createProxy(new ClassWithCounterConstructor(0)) - ); + $proxyName = (new AccessInterceptorScopeLocalizerFactory()) + ->createProxy(new ClassWithCounterConstructor(0))::class; /** @psalm-suppress UnsafeInstantiation it is allowed (by design) to instantiate these proxies */ $proxy = new $proxyName(15); @@ -441,9 +438,7 @@ public function testWillForwardVariadicArguments(): void $object = $factory->createProxy( $targetObject, [ - 'bar' => static function (): string { - return 'Foo Baz'; - }, + 'bar' => static fn (): string => 'Foo Baz', ] ); @@ -467,9 +462,7 @@ public function testWillForwardVariadicByRefArguments(): void $object = $factory->createProxy( $targetObject, [ - 'bar' => static function (): string { - return 'Foo Baz'; - }, + 'bar' => static fn (): string => 'Foo Baz', ] ); @@ -493,9 +486,7 @@ public function testWillNotForwardDynamicArguments(): void ->createProxy( new ClassWithDynamicArgumentsMethod(), [ - 'dynamicArgumentsMethod' => static function (): string { - return 'Foo Baz'; - }, + 'dynamicArgumentsMethod' => static fn (): string => 'Foo Baz', ] ); diff --git a/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php b/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php index 3e1d24b09..364ebe365 100644 --- a/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php @@ -32,7 +32,6 @@ use function array_values; use function assert; -use function get_class; use function is_callable; use function random_int; use function serialize; @@ -338,10 +337,8 @@ public function testWillBehaveLikeObjectWithNormalConstructor(): void self::assertSame(13, $instance->amount, 'Verifying that test asset works as expected'); self::assertSame(13, $instance->getAmount(), 'Verifying that test asset works as expected'); - $proxyName = get_class( - (new AccessInterceptorValueHolderFactory()) - ->createProxy(new ClassWithCounterConstructor(0)) - ); + $proxyName = (new AccessInterceptorValueHolderFactory()) + ->createProxy(new ClassWithCounterConstructor(0))::class; /** @psalm-suppress UnsafeInstantiation it is allowed (by design) to instantiate these proxies */ $proxy = new $proxyName(15); @@ -361,9 +358,7 @@ public function testWillForwardVariadicArguments(): void $object = $factory->createProxy( $targetObject, [ - 'bar' => static function (): string { - return 'Foo Baz'; - }, + 'bar' => static fn (): string => 'Foo Baz', ] ); @@ -383,9 +378,7 @@ public function testWillForwardVariadicByRefArguments(): void $object = (new AccessInterceptorValueHolderFactory())->createProxy( new ClassWithMethodWithByRefVariadicFunction(), [ - 'bar' => static function (): string { - return 'Foo Baz'; - }, + 'bar' => static fn (): string => 'Foo Baz', ] ); diff --git a/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php b/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php index f2a7dbd35..bb2a6feb9 100644 --- a/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php @@ -26,7 +26,7 @@ use function array_merge; use function get_declared_classes; use function realpath; -use function strpos; +use function str_starts_with; use function uniqid; /** @@ -59,9 +59,7 @@ public function testCodeGeneration(string $generatorClass, string $className): v $classGenerator->generate(new ReflectionClass($className), $generatedClass); $classSignatureGenerator->addSignature($generatedClass, ['key' => 'eval tests']); $generatorStrategy->generate($generatedClass); - } catch (ExceptionInterface $e) { - // empty catch: this is actually a supported failure - } catch (ReflectionException $e) { + } catch (ExceptionInterface | ReflectionException $e) { // empty catch: this is actually a supported failure } @@ -77,14 +75,10 @@ public function getTestedClasses(): array return array_merge( [], ...array_map( - function ($generator): array { - return array_map( - static function ($class) use ($generator): array { - return [$generator, $class]; - }, - $this->getProxyTestedClasses() - ); - }, + fn ($generator): array => array_map( + static fn ($class): array => [$generator, $class], + $this->getProxyTestedClasses() + ), [ AccessInterceptorScopeLocalizerGenerator::class, AccessInterceptorValueHolderGenerator::class, @@ -133,7 +127,7 @@ static function ($className) use ($skippedPaths): bool { foreach ($skippedPaths as $skippedPath) { self::assertIsString($skippedPath); - if (strpos($realPath, $skippedPath) === 0) { + if (str_starts_with($realPath, $skippedPath)) { // skip classes defined within ProxyManager, vendor or the test suite return false; } diff --git a/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php b/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php index 6dc2f5405..5179f1e90 100644 --- a/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php @@ -41,7 +41,6 @@ use function array_key_exists; use function array_values; use function assert; -use function get_class; use function get_parent_class; use function random_int; use function serialize; @@ -302,9 +301,7 @@ public function testWillModifyByRefRetrievedPublicProperties(): void public function testKeepsInitializerWhenNotOverwitten(): void { - $initializer = static function (): bool { - return true; - }; + $initializer = static fn (): bool => true; $proxy = (new LazyLoadingGhostFactory())->createProxy( BaseClass::class, @@ -353,9 +350,7 @@ public function testPublicPropertyDefaultWillBePreserved(): void { $proxy = (new LazyLoadingGhostFactory())->createProxy( ClassWithPublicProperties::class, - static function (): bool { - return true; - } + static fn (): bool => true ); self::assertSame('property0', $proxy->property0); @@ -368,9 +363,7 @@ public function testProtectedPropertyDefaultWillBePreserved(): void { $proxy = (new LazyLoadingGhostFactory())->createProxy( ClassWithProtectedProperties::class, - static function (): bool { - return true; - } + static fn (): bool => true ); // Check protected property via reflection @@ -387,9 +380,7 @@ public function testPrivatePropertyDefaultWillBePreserved(): void { $proxy = (new LazyLoadingGhostFactory())->createProxy( ClassWithPrivateProperties::class, - static function (): bool { - return true; - } + static fn (): bool => true ); // Check protected property via reflection @@ -407,9 +398,7 @@ public function testMultiLevelPrivatePropertiesDefaultsWillBePreserved(): void { $proxy = (new LazyLoadingGhostFactory())->createProxy( ClassWithCollidingPrivateInheritedProperties::class, - static function (): bool { - return true; - } + static fn (): bool => true ); $childProperty = new ReflectionProperty(ClassWithCollidingPrivateInheritedProperties::class, 'property0'); @@ -783,15 +772,11 @@ public function testWillBehaveLikeObjectWithNormalConstructor(): void self::assertSame(13, $instance->amount, 'Verifying that test asset works as expected'); self::assertSame(13, $instance->getAmount(), 'Verifying that test asset works as expected'); - $proxyName = get_class( - (new LazyLoadingGhostFactory()) - ->createProxy( - ClassWithCounterConstructor::class, - static function (): bool { - return true; - } - ) - ); + $proxyName = (new LazyLoadingGhostFactory()) + ->createProxy( + ClassWithCounterConstructor::class, + static fn (): bool => true + )::class; /** @psalm-suppress UnsafeInstantiation it is allowed (by design) to instantiate these proxies */ $proxy = new $proxyName(15); @@ -1152,9 +1137,7 @@ public function testWillForwardDynamicArguments(): void { $object = (new LazyLoadingGhostFactory())->createProxy( ClassWithDynamicArgumentsMethod::class, - static function (): bool { - return true; - } + static fn (): bool => true ); // first, testing normal variadic behavior (verifying we didn't screw up in the test asset) diff --git a/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php b/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php index 19d6c481a..96b56d0a8 100644 --- a/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php @@ -35,7 +35,6 @@ use function array_values; use function assert; -use function get_class; use function is_callable; use function random_int; use function serialize; @@ -314,15 +313,11 @@ public function testWillBehaveLikeObjectWithNormalConstructor(): void self::assertSame(13, $instance->amount, 'Verifying that test asset works as expected'); self::assertSame(13, $instance->getAmount(), 'Verifying that test asset works as expected'); - $proxyName = get_class( - (new LazyLoadingValueHolderFactory()) - ->createProxy( - ClassWithCounterConstructor::class, - static function (): bool { - return true; - } - ) - ); + $proxyName = (new LazyLoadingValueHolderFactory()) + ->createProxy( + ClassWithCounterConstructor::class, + static fn (): bool => true + )::class; /** @psalm-suppress UnsafeInstantiation it is allowed (by design) to instantiate these proxies */ $proxy = new $proxyName(15); diff --git a/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php b/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php index 07d1a9b9c..672c66d95 100644 --- a/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php +++ b/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php @@ -60,9 +60,7 @@ public function testCanGenerateMultipleDifferentProxiesForSameClass(object $obje $accessInterceptorFactory = new AccessInterceptorValueHolderFactory(); $accessInterceptorScopeLocalizerFactory = new AccessInterceptorScopeLocalizerFactory(); $className = $object::class; - $initializer = static function (): bool { - return true; - }; + $initializer = static fn (): bool => true; $generated = [ $ghostProxyFactory->createProxy($className, $initializer), diff --git a/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php b/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php index 042d8830a..b244176ae 100644 --- a/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php +++ b/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php @@ -60,9 +60,7 @@ protected function setUp(): void protected function tearDown(): void { - self::assertSame($this->originalErrorHandler, set_error_handler(static function (): bool { - return true; - })); + self::assertSame($this->originalErrorHandler, set_error_handler(static fn (): bool => true)); restore_error_handler(); restore_error_handler(); @@ -170,7 +168,7 @@ public function testWhenFailingAllTemporaryFilesAreRemoved(): void $generator->generate(new ClassGenerator($fqcn)); self::fail('An exception was supposed to be thrown'); - } catch (FileNotWritableException $exception) { + } catch (FileNotWritableException) { rmdir($tmpFile); self::assertEquals(['.', '..'], scandir($tmpDirPath, SCANDIR_SORT_ASCENDING)); diff --git a/tests/ProxyManagerTest/ProxyGenerator/Util/PropertiesTest.php b/tests/ProxyManagerTest/ProxyGenerator/Util/PropertiesTest.php index 35a24607e..ef1569dcf 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/Util/PropertiesTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/Util/PropertiesTest.php @@ -117,9 +117,7 @@ public function testOnlyNullableProperties(): void 'privateNullableObjectProperty', 'privateNullableClassProperty', ], - array_values(array_map(static function (ReflectionProperty $property): string { - return $property->getName(); - }, $nullablePublicProperties)) + array_values(array_map(static fn (ReflectionProperty $property): string => $property->getName(), $nullablePublicProperties)) ); } @@ -221,9 +219,7 @@ public function testOnlyPropertiesThatCanBeUnset(): void 'privateClassProperty', 'privateNullableClassProperty', ], - array_values(array_map(static function (ReflectionProperty $property): string { - return $property->getName(); - }, $nonReferenceableProperties)) + array_values(array_map(static fn (ReflectionProperty $property): string => $property->getName(), $nonReferenceableProperties)) ); } @@ -291,9 +287,7 @@ public function testOnlyNonReferenceableProperties(): void 'privateClassProperty', 'privateNullableClassProperty', ], - array_values(array_map(static function (ReflectionProperty $property): string { - return $property->getName(); - }, $nonReferenceableProperties)) + array_values(array_map(static fn (ReflectionProperty $property): string => $property->getName(), $nonReferenceableProperties)) ); } diff --git a/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php b/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php index f8e67be74..fe7bb90cb 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php @@ -43,9 +43,7 @@ public function testFiltering(ReflectionClass $reflectionClass, ?array $excludes $filtered = ProxiedMethodsFilter::getProxiedMethods($reflectionClass, $excludes); $keys = array_map( - static function (ReflectionMethod $method): string { - return $method->getName(); - }, + static fn (ReflectionMethod $method): string => $method->getName(), $filtered ); @@ -69,9 +67,7 @@ public function testFilteringOfAbstractPublic( $filtered = ProxiedMethodsFilter::getAbstractProxiedMethods($reflectionClass, $excludes); $keys = array_map( - static function (ReflectionMethod $method): string { - return $method->getName(); - }, + static fn (ReflectionMethod $method): string => $method->getName(), $filtered ); diff --git a/tests/static-analysis/lazy-loading-ghost-object.php b/tests/static-analysis/lazy-loading-ghost-object.php index fc6585060..af9c0dffb 100644 --- a/tests/static-analysis/lazy-loading-ghost-object.php +++ b/tests/static-analysis/lazy-loading-ghost-object.php @@ -38,9 +38,7 @@ static function ( $lazyLoadingGhost = (new LazyLoadingGhostFactory()) ->createProxy( MyProxiedClass::class, - static function () : bool { - return true; - } + static fn(): bool => true ); $lazyLoadingGhost->setProxyInitializer(static function (