Skip to content

Commit 7b98287

Browse files
authored
Add fixture that prefers required if found (#695)
1 parent 4d9e547 commit 7b98287

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture;
4+
5+
use Psr\EventDispatcher\EventDispatcherInterface;
6+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7+
8+
class PreferRequiredSetter extends Controller
9+
{
10+
private EventDispatcherInterface $eventDispatcher;
11+
12+
/**
13+
* @required
14+
*/
15+
public function autowire(
16+
EventDispatcherInterface $eventDispatcher
17+
) {
18+
$this->eventDispatcher = $eventDispatcher;
19+
}
20+
21+
22+
public function configure()
23+
{
24+
$someType = $this->get('validator');
25+
}
26+
}
27+
28+
?>
29+
-----
30+
<?php
31+
32+
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture;
33+
34+
use Psr\EventDispatcher\EventDispatcherInterface;
35+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
36+
use Symfony\Component\Validator\Validator\ValidatorInterface;
37+
38+
class PreferRequiredSetter extends Controller
39+
{
40+
private EventDispatcherInterface $eventDispatcher;
41+
42+
private ValidatorInterface $validator;
43+
44+
/**
45+
* @required
46+
*/
47+
public function autowire(
48+
EventDispatcherInterface $eventDispatcher,
49+
ValidatorInterface $validator
50+
) {
51+
$this->eventDispatcher = $eventDispatcher;
52+
$this->validator = $validator;
53+
}
54+
55+
56+
public function configure()
57+
{
58+
$someType = $this->validator;
59+
}
60+
}
61+
62+
?>

0 commit comments

Comments
 (0)