Task #33589

Issue warning / error when trying to @inject into private property

Added by Robert Lemke almost 10 years ago. Updated almost 10 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
Object
Start date:
2012-02-01
Due date:
% Done:

100%

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

Description

Class properties declared as private cannot be used for property injection by using the @FLOW3\Inject annotation because the proxy class can only set it in its own scope. If private properties are really necessary, constructor or setter injection can be used as a workaround.

FLOW3 should throw an exception on detecting an inject annotation on a private property.

#1

Updated by Robert Lemke almost 10 years ago

Hint: the exception should be thrown in the ConfigurationBuilder:

            foreach ($this->reflectionService->getPropertyNamesByTag($className, 'inject') as $propertyName) {
                if (!array_key_exists($propertyName, $properties)) {
                    $objectName = trim(implode('', $this->reflectionService->getPropertyTagValues($className, $propertyName, 'var')), ' \\');
                    $properties[$propertyName] =  new ConfigurationProperty($propertyName, $objectName, ConfigurationProperty::PROPERTY_TYPES_OBJECT);
                }
            }
#2

Updated by Adrian Föder almost 10 years ago

  • Status changed from New to Accepted
  • Assignee set to Adrian Föder
#3

Updated by Gerrit Code Review almost 10 years ago

  • Status changed from Accepted to Under Review

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

#4

Updated by Gerrit Code Review almost 10 years ago

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

#5

Updated by Gerrit Code Review almost 10 years ago

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

#6

Updated by Gerrit Code Review almost 10 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8794

#7

Updated by Adrian Föder almost 10 years ago

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

Also available in: Atom PDF