Created
January 11, 2019 22:12
-
-
Save SignpostMarv/af8836b001fe726df96dc006c9d4a65d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Reflection/Php/PhpParameterReflection.php b/src/Reflection/Php/PhpParameterReflection.php | |
index 02ce9255..03b8a5f2 100644 | |
--- a/src/Reflection/Php/PhpParameterReflection.php | |
+++ b/src/Reflection/Php/PhpParameterReflection.php | |
@@ -7,6 +7,7 @@ use PHPStan\Reflection\PassedByReference; | |
use PHPStan\Type\MixedType; | |
use PHPStan\Type\Type; | |
use PHPStan\Type\TypehintHelper; | |
+use ReflectionClass; | |
class PhpParameterReflection implements ParameterReflection | |
{ | |
@@ -52,6 +53,24 @@ class PhpParameterReflection implements ParameterReflection | |
$this->reflection->getDeclaringClass() !== null ? $this->reflection->getDeclaringClass()->getName() : null, | |
$this->isVariadic() | |
); | |
+ | |
+ if (($this->type instanceof MixedType) && ! $this->type->isExplicitMixed()) { | |
+ $traits = class_uses($this->reflection->getDeclaringClass()->getName()); | |
+ | |
+ $method = $this->reflection->getDeclaringFunction()->getName(); | |
+ | |
+ foreach ($traits as $trait) { | |
+ $traitRef = new ReflectionClass($trait); | |
+ | |
+ if ($traitRef->hasMethod($method)) { | |
+ /** | |
+ * @var \ReflectionMethod | |
+ */ | |
+ $traitMethod = $traitRef->getMethod($method); | |
+ $traitMethodParam = $traitMethod->getParameters()[$this->reflection->getPosition()] ?? null; | |
+ } | |
+ } | |
+ } | |
} | |
return $this->type; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment