Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary ParametersAcceptorSelector::selectSingle handling #9

Merged
merged 6 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading