Task #33589

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

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

Status:Resolved Start date:2012-02-01
Priority:Should have Due date:
Assigned To: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

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 3 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 3 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 3 years ago

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

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

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

Also available in: Atom PDF