From 5b2a664a984d73098af2c1ff0eb0d4f96bb22573 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 2 Oct 2024 13:37:57 +0200 Subject: [PATCH 1/6] Remove unnecessary `ParametersAcceptorSelector::selectSingle` handling --- .../MethodCall/ContainerGetReturnTypeExtension.php | 2 +- .../MethodCall/LaravelContainerMakeTypeExtension.php | 2 +- src/TypeResolver/ClassConstFetchReturnTypeResolver.php | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/TypeExtension/MethodCall/ContainerGetReturnTypeExtension.php b/src/TypeExtension/MethodCall/ContainerGetReturnTypeExtension.php index 91be7d41..2863beb9 100644 --- a/src/TypeExtension/MethodCall/ContainerGetReturnTypeExtension.php +++ b/src/TypeExtension/MethodCall/ContainerGetReturnTypeExtension.php @@ -38,7 +38,7 @@ public function getTypeFromMethodCall( MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope - ): Type { + ): ?Type { return $this->classConstFetchReturnTypeResolver->resolve($methodReflection, $methodCall); } } diff --git a/src/TypeExtension/MethodCall/LaravelContainerMakeTypeExtension.php b/src/TypeExtension/MethodCall/LaravelContainerMakeTypeExtension.php index 378749ae..be8fb5de 100644 --- a/src/TypeExtension/MethodCall/LaravelContainerMakeTypeExtension.php +++ b/src/TypeExtension/MethodCall/LaravelContainerMakeTypeExtension.php @@ -36,7 +36,7 @@ public function getTypeFromMethodCall( MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope - ): Type { + ): ?Type { return $this->classConstFetchReturnTypeResolver->resolve($methodReflection, $methodCall); } } diff --git a/src/TypeResolver/ClassConstFetchReturnTypeResolver.php b/src/TypeResolver/ClassConstFetchReturnTypeResolver.php index a2f9ab2c..6a280af4 100644 --- a/src/TypeResolver/ClassConstFetchReturnTypeResolver.php +++ b/src/TypeResolver/ClassConstFetchReturnTypeResolver.php @@ -18,10 +18,8 @@ final class ClassConstFetchReturnTypeResolver { - public function resolve(MethodReflection $methodReflection, MethodCall $methodCall): Type + public function resolve(MethodReflection $methodReflection, MethodCall $methodCall): ?Type { - $returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType(); - if (! isset($methodCall->args[0])) { throw new ShouldNotHappenException('Not supported without argument'); } @@ -45,6 +43,6 @@ public function resolve(MethodReflection $methodReflection, MethodCall $methodCa return new ObjectType($className); } - return $returnType; + return null; } } From d967424629fafeb10c7fa11cfdece6790835c783 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 11 Nov 2024 09:35:48 +0100 Subject: [PATCH 2/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e5e6e974..3593633a 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "illuminate/container": "^10.39", "phpstan/extension-installer": "^1.3", "phpunit/phpunit": "^10.3", - "rector/rector": "^0.18", + "rector/rector": "^1", "symfony/dependency-injection": "^6.4", "symfony/finder": "^6.2", "symplify/easy-coding-standard": "^12.0", From a557a1ae63edca7e80eb7243dbf36268e4d6a35f Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 11 Nov 2024 09:53:07 +0100 Subject: [PATCH 3/6] update class-leak --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3593633a..b0f749b3 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "symfony/finder": "^6.2", "symplify/easy-coding-standard": "^12.0", "symplify/phpstan-rules": "^12.4", - "tomasvotruba/class-leak": "^0.2", + "tomasvotruba/class-leak": "^1", "tracy/tracy": "^2.9" }, "autoload": { From fdb8e5f849533a0ecf58bf482b0660ebb0947aa9 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 11 Nov 2024 09:55:07 +0100 Subject: [PATCH 4/6] class-leak skip TypeExtenion classes --- .github/workflows/code_analysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index d82bc414..29b9ccff 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -38,7 +38,7 @@ jobs: - name: 'Check Active Classes' - run: vendor/bin/class-leak check src --ansi + run: vendor/bin/class-leak check src --ansi --skip-suffix "TypeExtension" name: ${{ matrix.actions.name }} runs-on: ubuntu-latest From 93a035fde27743bf2f9c1150d9a98176606b9a7e Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 11 Nov 2024 10:08:31 +0100 Subject: [PATCH 5/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b0f749b3..ee17c0b5 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "illuminate/container": "^10.39", "phpstan/extension-installer": "^1.3", "phpunit/phpunit": "^10.3", - "rector/rector": "^1", + "rector/rector": "^1.2", "symfony/dependency-injection": "^6.4", "symfony/finder": "^6.2", "symplify/easy-coding-standard": "^12.0", From d2cdc409920604dec0a839b8a531b00e04e5a526 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 11 Nov 2024 10:20:01 +0100 Subject: [PATCH 6/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ee17c0b5..64937a7b 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "symfony/finder": "^6.2", "symplify/easy-coding-standard": "^12.0", "symplify/phpstan-rules": "^12.4", - "tomasvotruba/class-leak": "^1", + "tomasvotruba/class-leak": "^1.1.2", "tracy/tracy": "^2.9" }, "autoload": {