Skip to content

Commit

Permalink
Add constructor fixture, just to verify alter behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jan 6, 2025
1 parent 56afd54 commit 5394ff6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Rector\Tests\Issues\AddClassDependency\Fixture;

use Rector\Tests\Issues\AddClassDependency\Source\SomeAutowiredService;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

final class StickWithConstructor extends Controller
{
public function __construct(
private SomeAutowiredService $someAutowiredService,
) {
}

public function configure()
{
$someType = $this->get('validator');
}
}

?>
-----
<?php

namespace Rector\Tests\Issues\AddClassDependency\Fixture;

use Rector\Tests\Issues\AddClassDependency\Source\SomeAutowiredService;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

final class StickWithConstructor extends Controller
{
public function __construct(
private SomeAutowiredService $someAutowiredService, private readonly \Symfony\Component\Validator\Validator\ValidatorInterface $validator,
) {
}

public function configure()
{
$someType = $this->validator;
}
}

?>
6 changes: 2 additions & 4 deletions tests/Issues/AddClassDependency/config/configured_rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

declare(strict_types=1);

use Rector\Symfony\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector;
use Rector\Config\RectorConfig;
use Rector\Symfony\DependencyInjection\Rector\Class_\GetBySymfonyStringToConstructorInjectionRector;

return RectorConfig::configure()
->withRules([
GetBySymfonyStringToConstructorInjectionRector::class,
]);
->withRules([GetBySymfonyStringToConstructorInjectionRector::class]);

0 comments on commit 5394ff6

Please sign in to comment.