Task #33589

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

Added by Robert Lemke over 7 years ago. Updated over 7 years ago.

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

100%

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.

Associated revisions

Revision 837fc980 (diff)
Added by Adrian Föder over 7 years ago

[TASK] Throw exception when private properties have @Inject

Properties annotated for injection do obviously have to
be at least protected in order for the proxy class
having access to it.
This patch makes an exception thrown when such private
properties occur.

Change-Id: I94c3bd81ee7242ccc341e657e9088877ada19103
Resolves: #33589
Releases: 1.1

History

#1 Updated by Robert Lemke over 7 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 over 7 years ago

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

#3 Updated by Gerrit Code Review over 7 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 over 7 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 over 7 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 over 7 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 over 7 years ago

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

Also available in: Atom PDF