|
|
@ -12,7 +12,7 @@ declare(strict_types=1); |
|
|
|
* with this source code in the file LICENSE. |
|
|
|
*/ |
|
|
|
|
|
|
|
namespace PhpCsFixer\Fixer\Import; |
|
|
|
namespace PhpCsFixerCustom; |
|
|
|
|
|
|
|
use PhpCsFixer\AbstractFixer; |
|
|
|
use PhpCsFixer\DocBlock\TypeExpression; |
|
|
@ -63,7 +63,7 @@ use PhpCsFixer\Tokenizer\Tokens; |
|
|
|
* |
|
|
|
* @phpstan-import-type _ImportType from \PhpCsFixer\Tokenizer\Analyzer\Analysis\NamespaceUseAnalysis |
|
|
|
*/ |
|
|
|
final class FullyQualifiedStrictTypesFixer extends AbstractFixer implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface |
|
|
|
final class CustomFullyQualifiedStrictTypesFixer extends AbstractFixer implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface |
|
|
|
{ |
|
|
|
/** @use ConfigurableFixerTrait<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration> */ |
|
|
|
use ConfigurableFixerTrait; |
|
|
@ -215,6 +215,11 @@ class Foo extends \Other\BaseClass implements \Other\Interface1, \Other\Interfac |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
public function getName(): string |
|
|
|
{ |
|
|
|
return 'Custom/fully_qualified_strict_types'; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* {@inheritdoc} |
|
|
|
* |
|
|
@ -250,7 +255,7 @@ class Foo extends \Other\BaseClass implements \Other\Interface1, \Other\Interfac |
|
|
|
'leading_backslash_in_global_namespace', |
|
|
|
'Whether FQCN is prefixed with backslash when that FQCN is used in global namespace context.' |
|
|
|
)) |
|
|
|
->setAllowedTypes(['bool']) |
|
|
|
->setAllowedTypes(['bool', \Closure::class]) |
|
|
|
->setDefault(false) |
|
|
|
->getOption(), |
|
|
|
(new FixerOptionBuilder( |
|
|
@ -522,6 +527,7 @@ class Foo extends \Other\BaseClass implements \Other\Interface1, \Other\Interfac |
|
|
|
$res = $fqcn; |
|
|
|
if ($namespaceName !== '' |
|
|
|
|| $this->configuration['leading_backslash_in_global_namespace'] === true |
|
|
|
|| ($this->configuration['leading_backslash_in_global_namespace'] instanceof \Closure && $this->configuration['leading_backslash_in_global_namespace']($res)) |
|
|
|
|| isset($this->cacheUseNameByShortNameLower[$importKind][strtolower(explode('\\', $res, 2)[0])]) |
|
|
|
) { |
|
|
|
$res = '\\' . $res; |
|
|
|