diff --git a/composer.json b/composer.json index 106ee29d8..987b95bd9 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "require": { "php": ">=5.3.1", "nette/neon": "~2.3", - "nette/reflection": "~2.2", + "nette/reflection": "~2.3", "nette/php-generator": "~2.2", "nette/utils": "~2.3" }, diff --git a/src/DI/Helpers.php b/src/DI/Helpers.php index ba8303f70..2c5c5a094 100644 --- a/src/DI/Helpers.php +++ b/src/DI/Helpers.php @@ -156,7 +156,7 @@ public static function getInjectProperties(Nette\Reflection\ClassType $class, $c throw new Nette\InvalidStateException("Property $property has no @var annotation."); } - $type = Nette\Reflection\AnnotationsParser::expandClassName($type, $property->getDeclaringClass()); + $type = Nette\Reflection\AnnotationsParser::expandClassName($type, Nette\Reflection\Helpers::getDeclaringClass($property)); if (!class_exists($type) && !interface_exists($type)) { throw new Nette\InvalidStateException("Class or interface '$type' used in @var annotation at $property not found. Check annotation and 'use' statements."); } elseif ($container && !$container->getByType($type, FALSE)) { diff --git a/tests/DI/Helpers.getInjectProperties().traits.phpt b/tests/DI/Helpers.getInjectProperties().traits.phpt new file mode 100644 index 000000000..4d519937e --- /dev/null +++ b/tests/DI/Helpers.getInjectProperties().traits.phpt @@ -0,0 +1,49 @@ + 'A\AInjected', + ), Helpers::getInjectProperties($refC) ); +}