-
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.
[DependencyInjection] Add GetBySymfonyStringToConstructorInjectionRec…
…tor (#688) * register rule * conver getContainer() as well * covert this container property fetch as well * deprecate ContainerGetToConstructorInjectionRector * deprecate ContainerGetToConstructorInjectionRector, as handles same logic as GetToConstructorInjectionRector * mark * misc
- Loading branch information
1 parent
da54cd8
commit 1138f04
Showing
34 changed files
with
391 additions
and
492 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
35 changes: 35 additions & 0 deletions
35
...Class_/CommandGetByTypeToConstructorInjectionRector/Fixture/include_get_container.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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\CommandGetByTypeToConstructorInjectionRector\Fixture; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
|
||
final class IncludeGetContainer extends ContainerAwareCommand | ||
{ | ||
public function configure() | ||
{ | ||
$someType = $this->getContainer()->get(SomeService::class); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\CommandGetByTypeToConstructorInjectionRector\Fixture; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
|
||
final class IncludeGetContainer extends ContainerAwareCommand | ||
{ | ||
public function __construct(private \Rector\Symfony\Tests\DependencyInjection\Rector\Class_\CommandGetByTypeToConstructorInjectionRector\Fixture\SomeService $someService) | ||
{ | ||
parent::__construct(); | ||
} | ||
public function configure() | ||
{ | ||
$someType = $this->someService; | ||
} | ||
} | ||
|
||
?> |
36 changes: 36 additions & 0 deletions
36
.../ControllerGetByTypeToConstructorInjectionRector/Fixture/cover_container_property.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,36 @@ | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\ControllerGetByTypeToConstructorInjectionRector\Fixture; | ||
|
||
use Rector\Symfony\Tests\DependencyInjection\Rector\Class_\ControllerGetByTypeToConstructorInjectionRector\Source\SomeService; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
final class CoverContainerProperty extends Controller | ||
{ | ||
public function configure() | ||
{ | ||
$someType = $this->container->get(SomeService::class); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\ControllerGetByTypeToConstructorInjectionRector\Fixture; | ||
|
||
use Rector\Symfony\Tests\DependencyInjection\Rector\Class_\ControllerGetByTypeToConstructorInjectionRector\Source\SomeService; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
final class CoverContainerProperty extends Controller | ||
{ | ||
public function __construct(private \Rector\Symfony\Tests\DependencyInjection\Rector\Class_\ControllerGetByTypeToConstructorInjectionRector\Source\SomeService $someService) | ||
{ | ||
} | ||
public function configure() | ||
{ | ||
$someType = $this->someService; | ||
} | ||
} | ||
|
||
?> |
34 changes: 34 additions & 0 deletions
34
...r/Class_/GetBySymfonyStringToConstructorInjectionRector/Fixture/command_validator.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,34 @@ | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
|
||
final class CommandValidator extends ContainerAwareCommand | ||
{ | ||
public function configure() | ||
{ | ||
$someType = $this->get('validator'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
|
||
final class CommandValidator extends ContainerAwareCommand | ||
{ | ||
public function __construct(private \Symfony\Component\Validator\Validator\ValidatorInterface $validator) | ||
{ | ||
} | ||
public function configure() | ||
{ | ||
$someType = $this->validator; | ||
} | ||
} | ||
|
||
?> |
34 changes: 34 additions & 0 deletions
34
...etBySymfonyStringToConstructorInjectionRector/Fixture/event_dispatcher_controller.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,34 @@ | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
final class EventDispatcherController extends Controller | ||
{ | ||
public function configure() | ||
{ | ||
$someType = $this->get('event_dispatcher'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector\Fixture; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
final class EventDispatcherController extends Controller | ||
{ | ||
public function __construct(private \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $eventDispatcher) | ||
{ | ||
} | ||
public function configure() | ||
{ | ||
$someType = $this->eventDispatcher; | ||
} | ||
} | ||
|
||
?> |
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
10 changes: 10 additions & 0 deletions
10
...n/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector/config/configured_rule.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Symfony\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(GetBySymfonyStringToConstructorInjectionRector::class); | ||
}; |
25 changes: 0 additions & 25 deletions
25
...l/ContainerGetToConstructorInjectionRector/Fixture/constant_as_service_regression.php.inc
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
...42/Rector/MethodCall/ContainerGetToConstructorInjectionRector/Fixture/first_class.php.inc
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
...y42/Rector/MethodCall/ContainerGetToConstructorInjectionRector/Fixture/my_command.php.inc
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...ctor/MethodCall/ContainerGetToConstructorInjectionRector/Fixture/skip_request_get.php.inc
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...Rector/MethodCall/ContainerGetToConstructorInjectionRector/Fixture/skip_test_case.php.inc
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...y42/Rector/MethodCall/ContainerGetToConstructorInjectionRector/Fixture/skip_trait.php.inc
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.