Skip to content

Commit de3b7fa

Browse files
committed
Update
1 parent bf692c1 commit de3b7fa

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

.php-cs-fixer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@
5858
unset($rules[PromotedConstructorPropertyFixer::name()]); // TODO: remove when dropping support to PHP <8.0
5959
unset($rules[TypedClassConstantFixer::name()]); // TODO: remove when dropping support to PHP <8.3
6060
$rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays']]; // TODO: remove when dropping support to PHP <8.0
61-
$rules[PhpdocNoNamedArgumentsTagFixer::name()] = ['directory' => __DIR__ . '/src/Analyzer/Analysis/']; // TODO: change to ['directory' => __DIR__ . '/src/']
61+
$rules[PhpdocNoNamedArgumentsTagFixer::name()] = false; // TODO: change to ['directory' => __DIR__ . '/src/']
6262

6363
$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type';
64+
$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'codeCoverageIgnoreStart';
65+
$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'codeCoverageIgnoreEnd';
6466

6567
foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) {
6668
$rules[$fixer->getName()] = true;

src/Fixer/PhpdocNoNamedArgumentsTagFixer.php

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ public function getConfigurationDefinition(): FixerConfigurationResolverInterfac
8282
throw new InvalidFixerConfigurationException($fixerName, \sprintf('The directory "%s" does not exists.', $value));
8383
}
8484

85-
$value = realpath($value) . \DIRECTORY_SEPARATOR;
86-
87-
return $value;
85+
return \realpath($value) . \DIRECTORY_SEPARATOR;
8886
})
8987
->getOption(),
9088
]);
@@ -150,30 +148,35 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
150148

151149
private function ensureIsDocBlockWithNoNameArgumentsTag(Tokens $tokens, int $index): void
152150
{
153-
/** @var \Closure(Tokens, int, WhitespacesFixerConfig): void $closure */
154-
static $closure;
155-
156-
if ($closure === null) {
157-
$function = function (Tokens $tokens, int $index, WhitespacesFixerConfig $whitespacesConfig): void {
158-
$object = new class () extends AbstractPhpUnitFixer implements WhitespacesAwareFixerInterface {
159-
public function ensureIsDocBlockWithNoNameArgumentsTag(Tokens $tokens, int $index, WhitespacesFixerConfig $whitespacesConfig): void
160-
{
161-
$this->setWhitespacesConfig($whitespacesConfig);
162-
$this->ensureIsDocBlockWithAnnotation($tokens, $index, 'no-named-arguments', ['no-named-arguments'], []);
163-
}
151+
static $abstractPhpUnitFixer;
152+
153+
if ($abstractPhpUnitFixer === null) {
154+
$abstractPhpUnitFixer = new class () extends AbstractPhpUnitFixer implements WhitespacesAwareFixerInterface {
155+
/**
156+
* @codeCoverageIgnoreStart
157+
*/
158+
protected function applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $endIndex): void
159+
{
160+
throw new \BadMethodCallException('Not implemented');
161+
}
164162

165-
protected function applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $endIndex): void {}
163+
public function getDefinition(): FixerDefinitionInterface
164+
{
165+
throw new \BadMethodCallException('Not implemented');
166+
}
166167

167-
public function getDefinition(): FixerDefinitionInterface
168-
{
169-
throw new \BadMethodCallException('Not implemented');
170-
}
171-
};
172-
$object->ensureIsDocBlockWithNoNameArgumentsTag($tokens, $index, $whitespacesConfig);
168+
/**
169+
* @codeCoverageIgnoreEnd
170+
*/
171+
public function ensureIsDocBlockWithNoNameArgumentsTag(Tokens $tokens, int $index, WhitespacesFixerConfig $whitespacesConfig): void
172+
{
173+
$this->setWhitespacesConfig($whitespacesConfig);
174+
$this->ensureIsDocBlockWithAnnotation($tokens, $index, 'no-named-arguments', ['no-named-arguments'], []);
175+
}
173176
};
174-
$closure = \Closure::bind($function, null, AbstractPhpUnitFixer::class);
175177
}
176178

177-
$closure($tokens, $index, $this->whitespacesConfig);
179+
// @phpstan-ignore method.nonObject
180+
$abstractPhpUnitFixer->ensureIsDocBlockWithNoNameArgumentsTag($tokens, $index, $this->whitespacesConfig);
178181
}
179182
}

0 commit comments

Comments
 (0)