Skip to content

Commit 22c80b1

Browse files
committed
ExtendedParameterReflection::hasNativeType()
1 parent 35fce62 commit 22c80b1

6 files changed

+29
-0
lines changed

src/Reflection/Annotations/AnnotationsMethodParameterReflection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public function getPhpDocType(): Type
3535
return $this->type;
3636
}
3737

38+
public function hasNativeType(): bool
39+
{
40+
return false;
41+
}
42+
3843
public function getNativeType(): Type
3944
{
4045
return new MixedType();

src/Reflection/ExtendedParameterReflection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ interface ExtendedParameterReflection extends ParameterReflection
1111

1212
public function getPhpDocType(): Type;
1313

14+
public function hasNativeType(): bool;
15+
1416
public function getNativeType(): Type;
1517

1618
public function getOutType(): ?Type;

src/Reflection/Native/ExtendedNativeParameterReflection.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPStan\Reflection\ExtendedParameterReflection;
66
use PHPStan\Reflection\PassedByReference;
77
use PHPStan\TrinaryLogic;
8+
use PHPStan\Type\MixedType;
89
use PHPStan\Type\Type;
910

1011
final class ExtendedNativeParameterReflection implements ExtendedParameterReflection
@@ -46,6 +47,11 @@ public function getPhpDocType(): Type
4647
return $this->phpDocType;
4748
}
4849

50+
public function hasNativeType(): bool
51+
{
52+
return !$this->nativeType instanceof MixedType || $this->nativeType->isExplicitMixed();
53+
}
54+
4955
public function getNativeType(): Type
5056
{
5157
return $this->nativeType;

src/Reflection/Php/ExtendedDummyParameter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPStan\Reflection\ExtendedParameterReflection;
66
use PHPStan\Reflection\PassedByReference;
77
use PHPStan\TrinaryLogic;
8+
use PHPStan\Type\MixedType;
89
use PHPStan\Type\Type;
910

1011
final class ExtendedDummyParameter extends DummyParameter implements ExtendedParameterReflection
@@ -32,6 +33,11 @@ public function getPhpDocType(): Type
3233
return $this->phpDocType;
3334
}
3435

36+
public function hasNativeType(): bool
37+
{
38+
return !$this->nativeType instanceof MixedType || $this->nativeType->isExplicitMixed();
39+
}
40+
3541
public function getNativeType(): Type
3642
{
3743
return $this->nativeType;

src/Reflection/Php/PhpParameterFromParserNodeReflection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public function getPhpDocType(): Type
6363
return $this->phpDocType ?? new MixedType();
6464
}
6565

66+
public function hasNativeType(): bool
67+
{
68+
return !$this->realType instanceof MixedType || $this->realType->isExplicitMixed();
69+
}
70+
6671
public function getNativeType(): Type
6772
{
6873
return $this->realType;

src/Reflection/Php/PhpParameterReflection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ public function getPhpDocType(): Type
9292
return new MixedType();
9393
}
9494

95+
public function hasNativeType(): bool
96+
{
97+
return $this->reflection->getType() !== null;
98+
}
99+
95100
public function getNativeType(): Type
96101
{
97102
if ($this->nativeType === null) {

0 commit comments

Comments
 (0)