Skip to content

Commit 547ad3c

Browse files
committed
Rename ResultInterface extension helpers to verb-first
1 parent 11cb1e4 commit 547ad3c

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/Type/ResultMethodReturnTypeExtension.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
6060
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type
6161
{
6262
return match ($methodReflection->getName()) {
63-
'getResult' => $this->resultType($methodCall, $scope),
64-
'getResultArray' => $this->listOf(new ArrayType(new StringType(), new MixedType())),
65-
'getResultObject' => $this->listOf(new ObjectType(stdClass::class)),
63+
'getResult' => $this->resolveResultType($methodCall, $scope),
64+
'getResultArray' => $this->wrapInList(new ArrayType(new StringType(), new MixedType())),
65+
'getResultObject' => $this->wrapInList(new ObjectType(stdClass::class)),
6666
'getRowArray' => TypeCombinator::addNull(new ArrayType(new StringType(), new MixedType())),
6767
'getRowObject' => TypeCombinator::addNull(new ObjectType(stdClass::class)),
68-
'getCustomResultObject' => $this->listOf($this->customObjectType($methodCall, $scope)),
68+
'getCustomResultObject' => $this->wrapInList($this->resolveCustomObject($methodCall, $scope)),
6969
default => null,
7070
};
7171
}
@@ -74,12 +74,12 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
7474
* Types `getResult($type)` from its constant `$type`: `'array'`, `'object'` (the default), or a
7575
* class name. A non-constant `$type` leaves the framework's declared `array`.
7676
*/
77-
private function resultType(MethodCall $methodCall, Scope $scope): ?Type
77+
private function resolveResultType(MethodCall $methodCall, Scope $scope): ?Type
7878
{
7979
$args = $methodCall->getArgs();
8080

8181
if (! isset($args[0])) {
82-
return $this->listOf(new ObjectType(stdClass::class));
82+
return $this->wrapInList(new ObjectType(stdClass::class));
8383
}
8484

8585
$strings = $scope->getType($args[0]->value)->getConstantStrings();
@@ -91,13 +91,13 @@ private function resultType(MethodCall $methodCall, Scope $scope): ?Type
9191
$value = $strings[0]->getValue();
9292

9393
return match ($value) {
94-
'array' => $this->listOf(new ArrayType(new StringType(), new MixedType())),
95-
'object' => $this->listOf(new ObjectType(stdClass::class)),
96-
default => $this->listOf($this->reflectionProvider->hasClass($value) ? new ObjectType($value) : new ObjectWithoutClassType()),
94+
'array' => $this->wrapInList(new ArrayType(new StringType(), new MixedType())),
95+
'object' => $this->wrapInList(new ObjectType(stdClass::class)),
96+
default => $this->wrapInList($this->reflectionProvider->hasClass($value) ? new ObjectType($value) : new ObjectWithoutClassType()),
9797
};
9898
}
9999

100-
private function customObjectType(MethodCall $methodCall, Scope $scope): Type
100+
private function resolveCustomObject(MethodCall $methodCall, Scope $scope): Type
101101
{
102102
$args = $methodCall->getArgs();
103103

@@ -114,7 +114,7 @@ private function customObjectType(MethodCall $methodCall, Scope $scope): Type
114114
return new ObjectWithoutClassType();
115115
}
116116

117-
private function listOf(Type $itemType): Type
117+
private function wrapInList(Type $itemType): Type
118118
{
119119
return TypeCombinator::intersect(
120120
new ArrayType(new IntegerType(), $itemType),

0 commit comments

Comments
 (0)