Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use PhpCsFixerConfig\Rules\LibraryRules;
use PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer;
use PhpCsFixerCustomFixers\Fixer\PhpdocOnlyAllowedAnnotationsFixer;
use PhpCsFixerCustomFixers\Fixer\PhpdocTagNoNamedArgumentsFixer;
use PhpCsFixerCustomFixers\Fixer\PromotedConstructorPropertyFixer;
use PhpCsFixerCustomFixers\Fixer\TypedClassConstantFixer;
use PhpCsFixerCustomFixers\Fixers;
Expand Down Expand Up @@ -57,6 +58,7 @@
unset($rules[PromotedConstructorPropertyFixer::name()]); // TODO: remove when dropping support to PHP <8.0
unset($rules[TypedClassConstantFixer::name()]); // TODO: remove when dropping support to PHP <8.3
$rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays']]; // TODO: remove when dropping support to PHP <8.0
$rules[PhpdocTagNoNamedArgumentsFixer::name()] = ['directory' => __DIR__ . '/src/'];

$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type';

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG for PHP CS Fixer: custom fixers

## v3.27.0
- Add PhpdocTagNoNamedArgumentsFixer

## v3.26.0
- Add TypedClassConstantFixer

Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
![Tests](https://img.shields.io/badge/tests-3750-brightgreen.svg)
![Tests](https://img.shields.io/badge/tests-3788-brightgreen.svg)
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)

[![CI status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml/badge.svg)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml)
Expand Down Expand Up @@ -610,6 +610,23 @@ The `@var` annotation must be on a single line if it is the only content.
}
```

#### PhpdocTagNoNamedArgumentsFixer
There must be `@no-named-arguments` tag in PHPDoc of a class/enum/interface/trait.
Configuration options:
- `description` (`string`): description of the tag; defaults to `''`
- `directory` (`string`): directory in which apply the changes, empty value will result with current working directory (result of `getcwd` call); defaults to `''`
```diff
<?php
+
+/**
+ * @no-named-arguments
+ */
class Foo
{
public function bar(string $s) {}
}
```

#### PhpdocTypeListFixer
PHPDoc type `list` must be used instead of `array` without a key type.
DEPRECATED: use `phpdoc_list_type` instead.
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/AbstractFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use PhpCsFixer\Fixer\FixerInterface;
use PhpCsFixer\Preg;

/**
* @no-named-arguments
*/
abstract class AbstractFixer implements FixerInterface
{
final public static function name(): string
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/AbstractTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
abstract class AbstractTypesFixer extends AbstractFixer
{
final public function isCandidate(Tokens $tokens): bool
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/ClassConstantUsageFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class ClassConstantUsageFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/CommentSurroundedBySpacesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class CommentSurroundedBySpacesFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/CommentedOutFunctionFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*
* @phpstan-type _InputConfig array{functions?: list<string>}
* @phpstan-type _Config array{functions: list<string>}
*
* @no-named-arguments
*/
final class CommentedOutFunctionFixer extends AbstractFixer implements ConfigurableFixerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/ConstructorEmptyBracesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\Analyzer\ConstructorAnalyzer;

/**
* @no-named-arguments
*/
final class ConstructorEmptyBracesFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/DataProviderNameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*
* @phpstan-type _InputConfig array{prefix?: string, suffix?: string}
* @phpstan-type _Config array{prefix: string, suffix: string}
*
* @no-named-arguments
*/
final class DataProviderNameFixer extends AbstractFixer implements ConfigurableFixerInterface, DeprecatedFixerInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/DataProviderReturnTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/**
* @deprecated
*
* @no-named-arguments
*/
final class DataProviderReturnTypeFixer extends AbstractFixer implements DeprecatedFixerInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/DataProviderStaticFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*
* @phpstan-type _InputConfig array{force?: bool}
* @phpstan-type _Config array{force: bool}
*
* @no-named-arguments
*/
final class DataProviderStaticFixer extends AbstractFixer implements ConfigurableFixerInterface, DeprecatedFixerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/DeclareAfterOpeningTagFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\TokenRemover;

/**
* @no-named-arguments
*/
final class DeclareAfterOpeningTagFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/EmptyFunctionBodyFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class EmptyFunctionBodyFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/ForeachUseValueFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class ForeachUseValueFixer extends AbstractFixer
{
private const NOT_ALLOWED_NEXT_TOKENS = [
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/InternalClassCasingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/**
* @deprecated
*
* @no-named-arguments
*/
final class InternalClassCasingFixer extends AbstractFixer implements DeprecatedFixerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/IssetToArrayKeyExistsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\Analyzer\FunctionAnalyzer;

/**
* @no-named-arguments
*/
final class IssetToArrayKeyExistsFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/MultilineCommentOpeningClosingAloneFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class MultilineCommentOpeningClosingAloneFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/MultilinePromotedPropertiesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*
* @phpstan-type _InputConfig array{keep_blank_lines?: bool, minimum_number_of_parameters?: int}
* @phpstan-type _Config array{keep_blank_lines: bool, minimum_number_of_parameters: int}
*
* @no-named-arguments
*/
final class MultilinePromotedPropertiesFixer extends AbstractFixer implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoCommentedOutCodeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\TokenRemover;

/**
* @no-named-arguments
*/
final class NoCommentedOutCodeFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoDoctrineMigrationsGeneratedCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\TokenRemover;

/**
* @no-named-arguments
*/
final class NoDoctrineMigrationsGeneratedCommentFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/NoDuplicatedArrayKeyFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*
* @phpstan-type _InputConfig array{ignore_expressions?: bool}
* @phpstan-type _Config array{ignore_expressions: bool}
*
* @no-named-arguments
*/
final class NoDuplicatedArrayKeyFixer extends AbstractFixer implements ConfigurableFixerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoDuplicatedImportsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use PhpCsFixer\Tokenizer\Analyzer\NamespaceUsesAnalyzer;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoDuplicatedImportsFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoImportFromGlobalNamespaceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\TokenRemover;

/**
* @no-named-arguments
*/
final class NoImportFromGlobalNamespaceFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoLeadingSlashInGlobalNamespaceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PhpCsFixer\Tokenizer\CT;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoLeadingSlashInGlobalNamespaceFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoNullableBooleanTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoNullableBooleanTypeFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoPhpStormGeneratedCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\TokenRemover;

/**
* @no-named-arguments
*/
final class NoPhpStormGeneratedCommentFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoReferenceInFunctionDefinitionFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PhpCsFixer\Tokenizer\Analyzer\ArgumentsAnalyzer;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoReferenceInFunctionDefinitionFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/NoSuperfluousConcatenationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
*
* @phpstan-type _InputConfig array{allow_preventing_trailing_spaces?: bool}
* @phpstan-type _Config array{allow_preventing_trailing_spaces: bool}
*
* @no-named-arguments
*/
final class NoSuperfluousConcatenationFixer extends AbstractFixer implements ConfigurableFixerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoTrailingCommaInSinglelineFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PhpCsFixer\Tokenizer\CT;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoTrailingCommaInSinglelineFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoUselessCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoUselessCommentFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoUselessDirnameCallFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoUselessDirnameCallFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoUselessDoctrineRepositoryCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixerCustomFixers\TokenRemover;

/**
* @no-named-arguments
*/
final class NoUselessDoctrineRepositoryCommentFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoUselessParenthesisFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\CT;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoUselessParenthesisFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoUselessStrlenFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoUselessStrlenFixer extends AbstractFixer
{
public function getDefinition(): FixerDefinitionInterface
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/NoUselessWriteVisibilityFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;

/**
* @no-named-arguments
*/
final class NoUselessWriteVisibilityFixer extends AbstractFixer
{
/** @var non-empty-array<int, list<int>> */
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/NumericLiteralSeparatorFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*
* @phpstan-type _InputConfig array{binary?: bool, decimal?: bool, float?: bool, hexadecimal?: bool, octal?: bool}
* @phpstan-type _Config array{binary: bool, decimal: bool, float: bool, hexadecimal: bool, octal: bool}
*
* @no-named-arguments
*/
final class NumericLiteralSeparatorFixer extends AbstractFixer implements ConfigurableFixerInterface, DeprecatedFixerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fixer/PhpUnitAssertArgumentsOrderFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use PhpCsFixerCustomFixers\Analyzer\Analysis\ArgumentAnalysis;
use PhpCsFixerCustomFixers\Analyzer\FunctionAnalyzer;

/**
* @no-named-arguments
*/
final class PhpUnitAssertArgumentsOrderFixer extends AbstractFixer
{
private const ASSERTIONS = [
Expand Down
Loading