Task #33589

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

Added by Robert Lemke over 1 year ago. Updated over 1 year ago.

Status:Resolved Start date:2012-02-01
Priority:Should have Due date:
Assignee:Adrian Föder % Done:

100%

Category:Object
Target version:TYPO3 Flow Base Distribution - 1.1
Sprint: Has patch:No
PHP Version:5.3 Complexity:easy
Votes: 0

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
Added by Adrian Föder over 1 year 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

Updated by Robert Lemke over 1 year 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);
                }
            }

Updated by Adrian Föder over 1 year ago

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

Updated by Gerrit Code Review over 1 year 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

Updated by Gerrit Code Review over 1 year ago

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

Updated by Gerrit Code Review over 1 year ago

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

Updated by Gerrit Code Review over 1 year ago

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

Updated by Adrian Föder over 1 year ago

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

Also available in: Atom PDF