Skip to content

Commit

Permalink
Remove unnecessary ParametersAcceptorSelector::selectSingle handling (
Browse files Browse the repository at this point in the history
#9)

* Remove unnecessary `ParametersAcceptorSelector::selectSingle` handling

* Update composer.json

* update class-leak

* class-leak skip TypeExtenion classes

* Update composer.json

* Update composer.json

---------

Co-authored-by: Markus Staab <[email protected]>
  • Loading branch information
staabm and clxmstaab authored Nov 11, 2024
1 parent 5eb198b commit f88ab09
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"illuminate/container": "^10.39",
"phpstan/extension-installer": "^1.3",
"phpunit/phpunit": "^10.3",
"rector/rector": "^0.18",
"rector/rector": "^1.2",
"symfony/dependency-injection": "^6.4",
"symfony/finder": "^6.2",
"symplify/easy-coding-standard": "^12.0",
"symplify/phpstan-rules": "^12.4",
"tomasvotruba/class-leak": "^0.2",
"tomasvotruba/class-leak": "^1.1.2",
"tracy/tracy": "^2.9"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getTypeFromMethodCall(
MethodReflection $methodReflection,
MethodCall $methodCall,
Scope $scope
): Type {
): ?Type {
return $this->classConstFetchReturnTypeResolver->resolve($methodReflection, $methodCall);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getTypeFromMethodCall(
MethodReflection $methodReflection,
MethodCall $methodCall,
Scope $scope
): Type {
): ?Type {
return $this->classConstFetchReturnTypeResolver->resolve($methodReflection, $methodCall);
}
}
6 changes: 2 additions & 4 deletions src/TypeResolver/ClassConstFetchReturnTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -45,6 +43,6 @@ public function resolve(MethodReflection $methodReflection, MethodCall $methodCa
return new ObjectType($className);
}

return $returnType;
return null;
}
}

0 comments on commit f88ab09

Please sign in to comment.