|
6 | 6 | use PHPStan\Reflection\FunctionVariant;
|
7 | 7 | use PHPStan\Reflection\MethodReflection;
|
8 | 8 | use PHPStan\TrinaryLogic;
|
| 9 | +use PHPStan\Type\ArrayType; |
9 | 10 | use PHPStan\Type\Generic\TemplateTypeMap;
|
| 11 | +use PHPStan\Type\IntegerType; |
10 | 12 | use PHPStan\Type\MixedType;
|
| 13 | +use PHPStan\Type\NullType; |
| 14 | +use PHPStan\Type\StringType; |
11 | 15 | use PHPStan\Type\Type;
|
| 16 | +use PHPStan\Type\UnionType; |
12 | 17 |
|
13 | 18 | class MagicRepositoryMethodReflection implements MethodReflection
|
14 | 19 | {
|
@@ -70,13 +75,31 @@ public function getPrototype(): \PHPStan\Reflection\ClassMemberReflection
|
70 | 75 |
|
71 | 76 | public function getVariants(): array
|
72 | 77 | {
|
| 78 | + if (strpos($this->name, 'findBy') === 0) { |
| 79 | + $arguments = [ |
| 80 | + new DummyParameter('argument', new MixedType(), false, null, false, null), |
| 81 | + new DummyParameter('orderBy', new UnionType([new ArrayType(new StringType(), new StringType()), new NullType()]), true, null, false, null), |
| 82 | + new DummyParameter('limit', new UnionType([new IntegerType(), new NullType()]), true, null, false, null), |
| 83 | + new DummyParameter('offset', new UnionType([new IntegerType(), new NullType()]), true, null, false, null), |
| 84 | + ]; |
| 85 | + } elseif (strpos($this->name, 'findOneBy') === 0) { |
| 86 | + $arguments = [ |
| 87 | + new DummyParameter('argument', new MixedType(), false, null, false, null), |
| 88 | + new DummyParameter('orderBy', new UnionType([new ArrayType(new StringType(), new StringType()), new NullType()]), true, null, false, null), |
| 89 | + ]; |
| 90 | + } elseif (strpos($this->name, 'countBy') === 0) { |
| 91 | + $arguments = [ |
| 92 | + new DummyParameter('argument', new MixedType(), false, null, false, null), |
| 93 | + ]; |
| 94 | + } else { |
| 95 | + throw new \PHPStan\ShouldNotHappenException(); |
| 96 | + } |
| 97 | + |
73 | 98 | return [
|
74 | 99 | new FunctionVariant(
|
75 | 100 | TemplateTypeMap::createEmpty(),
|
76 | 101 | null,
|
77 |
| - [ |
78 |
| - new DummyParameter('parameter', new MixedType(), false, null, false, null), |
79 |
| - ], |
| 102 | + $arguments, |
80 | 103 | false,
|
81 | 104 | $this->type
|
82 | 105 | ),
|
|
0 commit comments