-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixture that prefers required if found (#695)
- Loading branch information
1 parent
4d9e547
commit 7b98287
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...ss_/GetBySymfonyStringToConstructorInjectionRector/Fixture/prefer_required_setter.php.inc
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,62 @@ | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture; | ||
|
||
use Psr\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
class PreferRequiredSetter extends Controller | ||
{ | ||
private EventDispatcherInterface $eventDispatcher; | ||
|
||
/** | ||
* @required | ||
*/ | ||
public function autowire( | ||
EventDispatcherInterface $eventDispatcher | ||
) { | ||
$this->eventDispatcher = $eventDispatcher; | ||
} | ||
|
||
|
||
public function configure() | ||
{ | ||
$someType = $this->get('validator'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture; | ||
|
||
use Psr\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\Validator\Validator\ValidatorInterface; | ||
|
||
class PreferRequiredSetter extends Controller | ||
{ | ||
private EventDispatcherInterface $eventDispatcher; | ||
|
||
private ValidatorInterface $validator; | ||
|
||
/** | ||
* @required | ||
*/ | ||
public function autowire( | ||
EventDispatcherInterface $eventDispatcher, | ||
ValidatorInterface $validator | ||
) { | ||
$this->eventDispatcher = $eventDispatcher; | ||
$this->validator = $validator; | ||
} | ||
|
||
|
||
public function configure() | ||
{ | ||
$someType = $this->validator; | ||
} | ||
} | ||
|
||
?> |