|
2 | 2 |
|
3 | 3 | namespace PHPStan\Type\Doctrine\Descriptors;
|
4 | 4 |
|
| 5 | +use Doctrine\DBAL\Platforms\AbstractPlatform; |
5 | 6 | use PHPStan\Reflection\ParametersAcceptorSelector;
|
6 | 7 | use PHPStan\Reflection\ReflectionProvider;
|
7 | 8 | use PHPStan\Type\MixedType;
|
| 9 | +use PHPStan\Type\ObjectType; |
8 | 10 | use PHPStan\Type\Type;
|
9 | 11 | use PHPStan\Type\TypeCombinator;
|
10 | 12 |
|
@@ -33,14 +35,22 @@ public function getType(): string
|
33 | 35 |
|
34 | 36 | public function getWritableToPropertyType(): Type
|
35 | 37 | {
|
36 |
| - $type = ParametersAcceptorSelector::selectSingle($this->reflectionProvider->getClass($this->type)->getNativeMethod('convertToPHPValue')->getVariants())->getReturnType(); |
| 38 | + $method = $this->reflectionProvider->getClass($this->type)->getNativeMethod('convertToPHPValue'); |
| 39 | + $type = ParametersAcceptorSelector::selectFromTypes([ |
| 40 | + new MixedType(), |
| 41 | + new ObjectType(AbstractPlatform::class), |
| 42 | + ], $method->getVariants(), false)->getReturnType(); |
37 | 43 |
|
38 | 44 | return TypeCombinator::removeNull($type);
|
39 | 45 | }
|
40 | 46 |
|
41 | 47 | public function getWritableToDatabaseType(): Type
|
42 | 48 | {
|
43 |
| - $type = ParametersAcceptorSelector::selectSingle($this->reflectionProvider->getClass($this->type)->getNativeMethod('convertToDatabaseValue')->getVariants())->getParameters()[0]->getType(); |
| 49 | + $method = $this->reflectionProvider->getClass($this->type)->getNativeMethod('convertToDatabaseValue'); |
| 50 | + $type = ParametersAcceptorSelector::selectFromTypes([ |
| 51 | + new MixedType(), |
| 52 | + new ObjectType(AbstractPlatform::class), |
| 53 | + ], $method->getVariants(), false)->getParameters()[0]->getType(); |
44 | 54 |
|
45 | 55 | return TypeCombinator::removeNull($type);
|
46 | 56 | }
|
|
0 commit comments