Skip to content

Commit 5394ff6

Browse files
committed
Add constructor fixture, just to verify alter behavior
1 parent 56afd54 commit 5394ff6

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Rector\Tests\Issues\AddClassDependency\Fixture;
4+
5+
use Rector\Tests\Issues\AddClassDependency\Source\SomeAutowiredService;
6+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7+
8+
final class StickWithConstructor extends Controller
9+
{
10+
public function __construct(
11+
private SomeAutowiredService $someAutowiredService,
12+
) {
13+
}
14+
15+
public function configure()
16+
{
17+
$someType = $this->get('validator');
18+
}
19+
}
20+
21+
?>
22+
-----
23+
<?php
24+
25+
namespace Rector\Tests\Issues\AddClassDependency\Fixture;
26+
27+
use Rector\Tests\Issues\AddClassDependency\Source\SomeAutowiredService;
28+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
29+
30+
final class StickWithConstructor extends Controller
31+
{
32+
public function __construct(
33+
private SomeAutowiredService $someAutowiredService, private readonly \Symfony\Component\Validator\Validator\ValidatorInterface $validator,
34+
) {
35+
}
36+
37+
public function configure()
38+
{
39+
$someType = $this->validator;
40+
}
41+
}
42+
43+
?>

tests/Issues/AddClassDependency/config/configured_rule.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use Rector\Symfony\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector;
65
use Rector\Config\RectorConfig;
6+
use Rector\Symfony\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector;
77

88
return RectorConfig::configure()
9-
->withRules([
10-
GetBySymfonyStringToConstructorInjectionRector::class,
11-
]);
9+
->withRules([GetBySymfonyStringToConstructorInjectionRector::class]);

0 commit comments

Comments
 (0)