Bug #47114
@var annotations with included variable throw exception
Status: | Resolved | Start date: | 2013-04-10 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Alexander Berl | % Done: | 100% |
|
Category: | Property | |||
Target version: | - | |||
PHP Version: | Complexity: | easy | ||
Has patch: | No | Affected Flow version: | Git 2.0 |
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), ' \\');
Associated revisions
[BUGFIX] Allow variable name references in @var annotations
This change loosens the strictness of the @var annotation parsing, where
it would throw an exception when the annotation contained the variable
name it referred to.
So this is now possible::
/**
* @var integer $variable
*/
Change-Id: I0c7fbdd637a7e6e215cb0069270640488c55953e
Fixes: #47114
Releases: master
History
#1 Updated by Adrian Föder over 2 years ago
would you say that relates to https://review.typo3.org/#/c/19079/ ?
#2 Updated by Alexander Berl over 2 years ago
- Assigned To 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 over 2 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 over 2 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 over 2 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 over 2 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 2 years ago
- Category set to Property
#8 Updated by Robert Lemke about 2 years ago
- Target version deleted (
2.1)
#9 Updated by Alexander Berl about 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 4395bcba3a3b49abb16388e05c3ba2e176dd8915.