Bug #57034

Dependency injection for imported namespaces fails for collection classes

Added by Bastian Waidelich over 1 year ago. Updated over 1 year ago.

Status:Resolved Start date:2014-03-18
Priority:Must have Due date:
Assigned To:Bastian Waidelich % Done:

100%

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

Description

In our 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.
So while this works:

 1class SomeClass {
 2
 3    /**
 4     * @var \Doctrine\Common\Collections\Collection<\Some\Package\Domain\Model\SubEntity>
 5     */
 6    protected $subEntities;
 7
 8    /**
 9     * @param \Doctrine\Common\Collections\Collection<\Some\Package\Domain\Model\SubEntity>$subEntities
10     */
11    public function setSubEntities(\Doctrine\Common\Collections\Collection $subEntities) {
12        $this->subEntities = $subEntities;
13    }
14
15}

This will currently throw an exception:

 1use Doctrine\Common\Collections\Collection;
 2use Some\Package\Domain\Model\SubEntity as ImportedSubEntity;
 3
 4class SomeClass {
 5
 6    /**
 7     * @var Collection<ImportedSubEntity>
 8     */
 9    protected $subEntities;
10
11    /**
12     * @param Collection<ImportedSubEntity>$subEntities
13     */
14    public function setSubEntities(Collection $subEntities) {
15        $this->subEntities = $subEntities;
16    }
17
18}


Related issues

related to TYPO3.Flow - Bug #46008: Reflection should resolve relative namespaces Resolved 2013-03-04
related to TYPO3.Flow - Bug #50909: Dependency injection for imported namespaces fails for ab... Resolved 2013-08-08

Associated revisions

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&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 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 Gerrit Code Review over 1 year ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/28490

#2 Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch 2.2 of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/28554

#3 Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch 2.1 of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/28555

#4 Updated by Bastian Waidelich over 1 year ago

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

Also available in: Atom PDF