Skip to content

Commit

Permalink
[AutoImport] Do not add cast on valid Integer type on Name Node on au…
Browse files Browse the repository at this point in the history
…to import enabled
  • Loading branch information
samsonasik committed Aug 16, 2024
1 parent 3ed476b commit 7bed825
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Rector\Tests\Issues\AutoImport\Fixture;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DoNotAddCastValidInTypeFromName extends Command
{
private ?OutputInterface $outputInterface = null;

protected function execute(InputInterface $input, OutputInterface $output): int
{
return Command::SUCCESS;
}
}

?>
-----
<?php

namespace Rector\Tests\Issues\AutoImport\Fixture;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DoNotAddCastValidInTypeFromName extends Command
{
protected function execute(InputInterface $input, OutputInterface $output): int
{
return Command::SUCCESS;
}
}

?>
6 changes: 6 additions & 0 deletions tests/Issues/AutoImport/config/configured_rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
use Rector\Symfony\Symfony44\Rector\ClassMethod\ConsoleExecuteReturnIntRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->importNames();
Expand All @@ -18,4 +20,8 @@
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
new AnnotationToAttribute('Doctrine\ORM\Mapping\Entity'),
]);
$rectorConfig->rules([
ConsoleExecuteReturnIntRector::class,
RemoveUnusedPrivatePropertyRector::class,
]);
};

0 comments on commit 7bed825

Please sign in to comment.