-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add autowiring-support for PHP7.4 typed properties
The current implementation prioritizes `@var` and the `name` property of the `@Inject` annotation over the type of the property. This allows to still inject custom-named entries into the properties even in the presence of types.
- Loading branch information
Showing
4 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/UnitTest/Definition/Source/Fixtures/AnnotationFixtureScalarTypedProperty.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DI\Test\UnitTest\Definition\Source\Fixtures; | ||
|
||
class AnnotationFixtureScalarTypedProperty | ||
{ | ||
/** | ||
* @Inject | ||
*/ | ||
protected int $scalarTypeAndInject; | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/UnitTest/Definition/Source/Fixtures/AnnotationFixtureTypedProperties.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DI\Test\UnitTest\Definition\Source\Fixtures; | ||
|
||
class AnnotationFixtureTypedProperties | ||
{ | ||
protected AnnotationFixture2 $typedButNoInject; | ||
|
||
/** | ||
* @Inject | ||
*/ | ||
protected AnnotationFixture2 $typedAndInject; | ||
|
||
/** | ||
* @Inject | ||
* @var AnnotationFixture3 | ||
*/ | ||
protected AnnotationFixture2 $typedAndVar; | ||
|
||
/** | ||
* @Inject("name") | ||
*/ | ||
protected AnnotationFixture2 $typedAndNamed; | ||
} |