Skip to content

Commit

Permalink
fix: FullyQualifiedStrictTypesFixer - fix return types (#8367)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos authored Jan 12, 2025
1 parent 50594cc commit 3d83a57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Fixer/Import/FullyQualifiedStrictTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
}

$this->fixPhpDoc($tokens, $index, $uses, $namespaceName);
} elseif ($tokens[$index]->isGivenKind(CT::T_TYPE_COLON)) {
$this->fixNextName($tokens, $index, $uses, $namespaceName);
}

$indexDiff += \count($tokens) - $origSize;
Expand Down
15 changes: 15 additions & 0 deletions tests/Fixer/Import/FullyQualifiedStrictTypesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,21 @@ public function f(Exception $exception);
}
PHP,
];

yield 'fix arrow function return type' => [
<<<'PHP'
<?php
namespace Foo;
use Lib\Package\Bar;
$function = fn (): Bar => new Bar();
PHP,
<<<'PHP'
<?php
namespace Foo;
$function = fn (): \Lib\Package\Bar => new \Lib\Package\Bar();
PHP,
['import_symbols' => true],
];
}

/**
Expand Down

0 comments on commit 3d83a57

Please sign in to comment.