mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-20 06:38:46 +01:00
* #4013: Don't force type hint if already forced. * Fixes #4013 ConsoleExecuteReturnIntRector ignores already type casted variable Signed-off-by: Abdul Malik Ikhsan <samsonasik@gmail.com> * remove no expected change already casted variable fixture Signed-off-by: Abdul Malik Ikhsan <samsonasik@gmail.com> * remove unneded $hasReturn fill on check node->expr instanceof Int_ Co-authored-by: Aerendir <hello@aerendir.me>
This commit is contained in:
parent
95bbb3063c
commit
3d2a35d63e
@ -112,6 +112,10 @@ PHP
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($node->expr instanceof Int_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// is there return without nesting?
|
||||
if ($this->areNodesEqual($node->getAttribute(AttributeKey::PARENT_NODE), $classMethod)) {
|
||||
$hasReturn = true;
|
||||
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Symfony\Tests\Rector\ClassMethod\ConsoleExecuteReturnIntRector\Fixture;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
abstract class AbstractSkipAlreadyTypeHintedCommand extends Command
|
||||
{
|
||||
public function execute(InputInterface $input, OutputInterface $output):int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
final class SkipAlreadyTypeHintedCommand extends AbstractSkipAlreadyTypeHintedCommand
|
||||
{
|
||||
protected static $defaultName = 'shq:user:create';
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output):int
|
||||
{
|
||||
$initialized = parent::execute($input, $output);
|
||||
if (0 !== $initialized) {
|
||||
return (int) $initialized;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user