Bug #50909

Dependency injection for imported namespaces fails for abstract classes

Added by Philipp Maier almost 2 years ago. Updated almost 2 years ago.

Status:Resolved Start date:2013-08-08
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:Reflection
Target version:-
PHP Version: Complexity:
Has patch:No Affected Flow version:Git master

Description

Within abstract classes, the @var annotation still must be fully qualified.

Working:

abstract class SomeClass {

        ...

    /**
     * @var \TYPO3\Flow\Security\Context
     * @Flow\Inject
     */
    protected $securityContext;

Not working:

use TYPO3\Flow\Security\Context;

abstract class SomeClass {

        ...

    /**
     * @var Context
     * @Flow\Inject
     */
    protected $securityContext;


Related issues

related to TYPO3.Flow - Bug #46008: Reflection should resolve relative namespaces Resolved 2013-03-04
related to TYPO3.Flow - Bug #57034: Dependency injection for imported namespaces fails for co... Resolved 2014-03-18

Associated revisions

Revision 751b4b55
Added by Bastian Waidelich almost 2 years ago

[BUGFIX] Fix resolving of relative namespaces in parent classes

With I28fd7c7993ea79714cc62032fcc332ac8cf9d4bc the ReflectionService
resolves relative and aliased namespaces automatically.
This doesn't work for inherited classes though because the code only
considered the current class, not it's parents.

With this change code like this will work::

use TYPO3\Flow\Security\Context;
class SomeParentClass {
/**
  • @var Context
  • @Flow\Inject
    */
    protected $securityContext;
// ...
}
class SomeChildClass extends SomeParentClass {
}

Change-Id: Ie4b931a03a94d506890e996b9d8bae7d0d1a2e14
Fixes: #50909
Related: #46008
Releases: master

Revision ca5dd2ca
Added by Bastian Waidelich over 1 year ago

[BUGFIX] Fix resolving of imported collection types

This change extends the ReflectionService so that it is able to
expand our custom notation for collection types::

CollectionType<ElementType>

Background:

In the Coding Guidelines we encourage developers to import namespaces
in order to increase readability.

With #46008 the ReflectionService is able to resolve relative and
imported namespace (with #50909 this also works for abstract classes).

But this does not work for our custom notation of Collection types yet.
With this fix relative and imported class names are supported also for
our custom notation of collection types and the above would be
expanded to::

\CollectionTypeNamespace\CollectionType<\ElementTypeNamespace\ElementType>

Change-Id: I4e228d6846776d2500d7e8aec2bc88df170bc9de
Fixes: #57034
Related: #46008
Related: #50909
Releases: master, 2.2, 2.1

Revision 0b45aa53
Added by Bastian Waidelich over 1 year ago

[BUGFIX] Fix resolving of imported collection types

This change extends the ReflectionService so that it is able to
expand our custom notation for collection types::

CollectionType&lt;ElementType&gt;

Background:

In the Coding Guidelines we encourage developers to import namespaces
in order to increase readability.

With #46008 the ReflectionService is able to resolve relative and
imported namespace (with #50909 this also works for abstract classes).

But this does not work for our custom notation of Collection types yet.
With this fix relative and imported class names are supported also for
our custom notation of collection types and the above would be
expanded to::

\CollectionTypeNamespace\CollectionType<\ElementTypeNamespace\ElementType>

Change-Id: I4e228d6846776d2500d7e8aec2bc88df170bc9de
Fixes: #57034
Related: #46008
Related: #50909
Releases: master, 2.2, 2.1

Revision 4935af46
Added by Bastian Waidelich over 1 year ago

[BUGFIX] Fix resolving of imported collection types

This change extends the ReflectionService so that it is able to
expand our custom notation for collection types::

CollectionType&lt;ElementType&gt;

Background:

In the Coding Guidelines we encourage developers to import namespaces
in order to increase readability.

With #46008 the ReflectionService is able to resolve relative and
imported namespace (with #50909 this also works for abstract classes).

But this does not work for our custom notation of Collection types yet.
With this fix relative and imported class names are supported also for
our custom notation of collection types and the above would be
expanded to::

\CollectionTypeNamespace\CollectionType<\ElementTypeNamespace\ElementType>

Change-Id: I4e228d6846776d2500d7e8aec2bc88df170bc9de
Fixes: #57034
Related: #46008
Related: #50909
Releases: master, 2.2, 2.1

History

#1 Updated by Bastian Waidelich almost 2 years ago

  • Category set to Reflection
  • Status changed from New to Accepted
  • Priority changed from Must have to Should have

#2 Updated by Bastian Waidelich almost 2 years ago

  • Status changed from Accepted to Needs Feedback

Philipp, I can't reproduce this..
I have:

 1<?php
 2namespace Some\Package;
 3
 4use TYPO3\Flow\Annotations as Flow;
 5use TYPO3\Flow\Security\Context;
 6
 7abstract class SomeAbstractClass {
 8
 9    /**
10     * @var Context
11     * @Flow\Inject
12     */
13    protected $securityContext;
14
15    /**
16     * @return Context
17     */
18    public function getSecurityContext() {
19        return $this->securityContext;
20    }
21
22}
23?>

and

 1<?php
 2namespace Some\Package;
 3
 4use TYPO3\Flow\Annotations as Flow;
 5use TYPO3\Flow\Security\Context;
 6
 7class SomeClass extends SomeAbstractClass {
 8
 9}
10?>

and everything works as expected..!?

#3 Updated by Bastian Waidelich almost 2 years ago

  • Status changed from Needs Feedback to Accepted

Nevermind, I can reproduce it now

#4 Updated by Bastian Waidelich almost 2 years ago

FYI: I'm on it but this is harder than I thought..

#5 Updated by Gerrit Code Review almost 2 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/23310

#6 Updated by Gerrit Code Review almost 2 years ago

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

#7 Updated by Gerrit Code Review almost 2 years ago

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

#8 Updated by Bastian Waidelich almost 2 years ago

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

Also available in: Atom PDF