Bug #47114

@var annotations with included variable throw exception

Added by Alexander Berl about 8 years ago. Updated almost 7 years ago.

Status:
Resolved
Priority:
Should have
Category:
Property
Target version:
-
Start date:
2013-04-10
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:
easy

Description

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.

See ReflectionService@1231:

$declaredType = trim(implode(' ', $this->getPropertyTagValues($className, $propertyName, 'var')), ' \\');

instead:
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), ' \\');

#1

Updated by Adrian Föder about 8 years ago

would you say that relates to https://review.typo3.org/#/c/19079/ ?

#2

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.

#3

Updated by Gerrit Code Review about 8 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19860

#4

Updated by Gerrit Code Review about 8 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19860

#5

Updated by Gerrit Code Review about 8 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19860

#6

Updated by Gerrit Code Review about 8 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19860

#7

Updated by Robert Lemke about 8 years ago

  • Category set to Property
#8

Updated by Robert Lemke about 8 years ago

  • Target version deleted (2.1)
#9

Updated by Alexander Berl almost 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF