@var annotations with included variable throw exception
Currently all @var annotations which contain whitespaces are regarded as illformed and throw a InvalidPropertyTypeException.
However, it is common - at least for 3rd party code - to write @var annotations that look as follows:
/** * @var integer $number */ protected $number;
A good example for this are the gedmo doctrine extensions.
Hence I suggest to parse out all variable references in the annotation before deciding on being illformed.
$declaredType = trim(implode(' ', $this->getPropertyTagValues($className, $propertyName, 'var')), ' \\');
const VARIABLE_NAME_REGEX = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/'; ... $declaredType = implode(' ', $this->getPropertyTagValues($className, $propertyName, 'var')); $declaredType = trim(preg_replace(self::VARIABLE_NAME_REGEX, '', $declaredType), ' \\');
Updated by Alexander Berl about 8 years ago
- Assignee set to Alexander Berl
Only loosely, my as #19079 refers to the validation, while this refers to the parsing of classes in the ReflectionService. So it only relates for those cases where the @var annotation wasn't parsed at all, because else one wouldn't even get to the validation step.