Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add initial in-statements indent support #7901

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Fixer/ClassNotation/FinalClassFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class MyApp {}
),
],
'No exception and no configuration are intentional. Beside Doctrine entities and of course abstract classes, there is no single reason not to declare all classes final. '
.'If you want to subclass a class, mark the parent class as abstract and create two child classes, one empty if necessary: you\'ll gain much more fine grained type-hinting. '
.'If you need to mock a standalone class, create an interface, or maybe it\'s a value-object that shouldn\'t be mocked at all. '
.'If you need to extend a standalone class, create an interface and use the Composite pattern. '
.'If you aren\'t ready yet for serious OOP, go with FinalInternalClassFixer, it\'s fine.',
.'If you want to subclass a class, mark the parent class as abstract and create two child classes, one empty if necessary: you\'ll gain much more fine grained type-hinting. '
.'If you need to mock a standalone class, create an interface, or maybe it\'s a value-object that shouldn\'t be mocked at all. '
.'If you need to extend a standalone class, create an interface and use the Composite pattern. '
.'If you aren\'t ready yet for serious OOP, go with FinalInternalClassFixer, it\'s fine.',
'Risky when subclassing non-abstract classes.'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function start()
),
],
'Enforce API encapsulation in an inheritance architecture. '
.'If you want to override a method, use the Template method pattern.',
.'If you want to override a method, use the Template method pattern.',
'Risky when overriding `public` methods of `abstract` classes.'
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/ClassNotation/OrderedInterfacesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
? \strlen($first['normalized']) - \strlen($second['normalized'])
: (
true === $this->configuration['case_sensitive']
? $first['normalized'] <=> $second['normalized']
: strcasecmp($first['normalized'], $second['normalized'])
? $first['normalized'] <=> $second['normalized']
: strcasecmp($first['normalized'], $second['normalized'])
);

if (self::DIRECTION_DESCEND === $this->configuration[self::OPTION_DIRECTION]) {
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/FunctionNotation/VoidReturnFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private function hasVoidReturn(Tokens $tokens, int $startIndex, int $endIndex):
if (
// skip anonymous classes
($tokens[$i]->isGivenKind(T_CLASS) && $tokensAnalyzer->isAnonymousClass($i))
// skip lambda functions
// skip lambda functions
|| ($tokens[$i]->isGivenKind(T_FUNCTION) && $tokensAnalyzer->isLambda($i))
) {
$i = $tokens->getNextTokenOfKind($i, ['{']);
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/LanguageConstruct/NoUnsetOnPropertyFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function getDefinition(): FixerDefinitionInterface
[new CodeSample("<?php\nunset(\$this->a);\n")],
null,
'Risky when relying on attributes to be removed using `unset` rather than be set to `null`.'.
' Changing variables to `null` instead of unsetting means these still show up when looping over class variables'.
' and reference properties remain unbroken.'.
' With PHP 7.4, this rule might introduce `null` assignments to properties whose type declaration does not allow it.'
' Changing variables to `null` instead of unsetting means these still show up when looping over class variables'.
' and reference properties remain unbroken.'.
' With PHP 7.4, this rule might introduce `null` assignments to properties whose type declaration does not allow it.'
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/PhpUnit/PhpUnitDataProviderStaticFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
(new FixerOptionBuilder(
'force',
'Whether to make the data providers static even if they have a dynamic class call'
.' (may introduce fatal error "using $this when not in object context",'
.' and you may have to adjust the code manually by converting dynamic calls to static ones).'
.' (may introduce fatal error "using $this when not in object context",'
.' and you may have to adjust the code manually by converting dynamic calls to static ones).'
))
->setAllowedTypes(['bool'])
->setDefault(false)
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function testSomething()
new CodeSample($codeSample, ['target' => PhpUnitTargetVersion::VERSION_4_8]),
],
"PHPUnit v6 has finally fully switched to namespaces.\n"
."You could start preparing the upgrade by switching from non-namespaced TestCase to namespaced one.\n"
.'Forward compatibility layer (`\PHPUnit\Framework\TestCase` class) was backported to PHPUnit v4.8.35 and PHPUnit v5.4.0.'."\n"
.'Extended forward compatibility layer (`PHPUnit\Framework\Assert`, `PHPUnit\Framework\BaseTestListener`, `PHPUnit\Framework\TestListener` classes) was introduced in v5.7.0.'."\n",
."You could start preparing the upgrade by switching from non-namespaced TestCase to namespaced one.\n"
.'Forward compatibility layer (`\PHPUnit\Framework\TestCase` class) was backported to PHPUnit v4.8.35 and PHPUnit v5.4.0.'."\n"
.'Extended forward compatibility layer (`PHPUnit\Framework\Assert`, `PHPUnit\Framework\BaseTestListener`, `PHPUnit\Framework\TestListener` classes) was introduced in v5.7.0.'."\n",
'Risky when PHPUnit classes are overridden or not accessible, or when project has PHPUnit incompatibilities.'
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpUnit/PhpUnitSetUpTearDownVisibilityFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function tearDown()
],
null,
'This fixer may change functions named `setUp()` or `tearDown()` outside of PHPUnit tests, '.
'when a class is wrongly seen as a PHPUnit test.'
'when a class is wrongly seen as a PHPUnit test.'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testItDoesSomething() {}}'.$this->whitespacesConfig->getLineEndi
],
null,
'This fixer may change the name of your tests, and could cause incompatibility with'.
' abstract classes or interfaces.'
' abstract classes or interfaces.'
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Phpdoc/PhpdocAlignFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ private function fixDocBlock(DocBlock $docBlock): void
.$item['var']
.(
'' !== $item['desc']
? $this->getIndent($varMax - \strlen($item['var']) + $spacingForTag, $spacingForTag).$item['desc']
: ''
? $this->getIndent($varMax - \strlen($item['var']) + $spacingForTag, $spacingForTag).$item['desc']
: ''
);
} elseif ('' !== $item['desc']) {
$line .= $this->getIndent($hintMax - \strlen($item['hint']) + $spacingForTag, $spacingForTag).$item['desc'];
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Phpdoc/PhpdocSeparationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
if ($groupIndex === $tags[$member]) {
throw new InvalidOptionsException(
'The option "groups" value is invalid. '.
'The "'.$member.'" tag is specified more than once.'
'The "'.$member.'" tag is specified more than once.'
);
}

throw new InvalidOptionsException(
'The option "groups" value is invalid. '.
'The "'.$member.'" tag belongs to more than one group.'
'The "'.$member.'" tag belongs to more than one group.'
);
}
$tags[$member] = $groupIndex;
Expand Down
12 changes: 6 additions & 6 deletions src/Fixer/StringNotation/EscapeImplicitBackslashesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ public function getDefinition(): FixerDefinitionInterface
),
],
'In PHP double-quoted strings and heredocs some chars like `n`, `$` or `u` have special meanings if preceded by a backslash '
.'(and some are special only if followed by other special chars), while a backslash preceding other chars are interpreted like a plain '
.'backslash. The precise list of those special chars is hard to remember and to identify quickly: this fixer escapes backslashes '
."that do not start a special interpretation with the char after them.\n"
.'It is possible to fix also single-quoted strings: in this case there is no special chars apart from single-quote and backslash '
.'itself, so the fixer simply ensure that all backslashes are escaped. Both single and double backslashes are allowed in single-quoted '
.'strings, so the purpose in this context is mainly to have a uniformed way to have them written all over the codebase.'
.'(and some are special only if followed by other special chars), while a backslash preceding other chars are interpreted like a plain '
.'backslash. The precise list of those special chars is hard to remember and to identify quickly: this fixer escapes backslashes '
."that do not start a special interpretation with the char after them.\n"
.'It is possible to fix also single-quoted strings: in this case there is no special chars apart from single-quote and backslash '
.'itself, so the fixer simply ensure that all backslashes are escaped. Both single and double backslashes are allowed in single-quoted '
.'strings, so the purpose in this context is mainly to have a uniformed way to have them written all over the codebase.'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/StringNotation/ExplicitStringVariableFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getDefinition(): FixerDefinitionInterface
."\n".'- PHP manual marks `"$var"` syntax as implicit and `"${var}"` syntax as explicit: explicit code should always be preferred.'
."\n".'- Explicit syntax allows word concatenation inside strings, e.g. `"${var}IsAVar"`, implicit doesn\'t.'
."\n".'- Explicit syntax is easier to detect for IDE/editors and therefore has colors/highlight with higher contrast, which is easier to read.'
."\n".'Backtick operator is skipped because it is harder to handle; you can use `backtick_to_shell_exec` fixer to normalize backticks to strings.'
."\n".'Backtick operator is skipped because it is harder to handle; you can use `backtick_to_shell_exec` fixer to normalize backticks to strings.'
);
}

Expand Down
12 changes: 6 additions & 6 deletions src/Fixer/StringNotation/StringImplicitBackslashesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public function getDefinition(): FixerDefinitionInterface
),
],
'In PHP double-quoted strings and heredocs some chars like `n`, `$` or `u` have special meanings if preceded by a backslash '
.'(and some are special only if followed by other special chars), while a backslash preceding other chars are interpreted like a plain '
.'backslash. The precise list of those special chars is hard to remember and to identify quickly: this fixer escapes backslashes '
."that do not start a special interpretation with the char after them.\n"
.'It is possible to fix also single-quoted strings: in this case there is no special chars apart from single-quote and backslash '
.'itself, so the fixer simply ensure that all backslashes are escaped. Both single and double backslashes are allowed in single-quoted '
.'strings, so the purpose in this context is mainly to have a uniformed way to have them written all over the codebase.'
.'(and some are special only if followed by other special chars), while a backslash preceding other chars are interpreted like a plain '
.'backslash. The precise list of those special chars is hard to remember and to identify quickly: this fixer escapes backslashes '
."that do not start a special interpretation with the char after them.\n"
.'It is possible to fix also single-quoted strings: in this case there is no special chars apart from single-quote and backslash '
.'itself, so the fixer simply ensure that all backslashes are escaped. Both single and double backslashes are allowed in single-quoted '
.'strings, so the purpose in this context is mainly to have a uniformed way to have them written all over the codebase.'
);
}

Expand Down