Skip to content

Commit

Permalink
minor #5319 Clean ups (SpacePossum)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.17 branch.

Discussion
----------

Clean ups

Commits
-------

9001bad clean ups
  • Loading branch information
SpacePossum committed Dec 9, 2020
2 parents 9857ee1 + 9001bad commit ae6fcec
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 13 deletions.
4 changes: 2 additions & 2 deletions doc/rules/language_construct/single_space_after_construct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Configuration

List of constructs which must be followed by a single space.

Allowed values: a subset of ``['abstract', 'as', 'attribute', 'break', 'case', 'catch', 'class', 'clone', 'const', 'const_import', 'continue', 'do', 'echo', 'else', 'elseif', 'extends', 'final', 'finally', 'for', 'foreach', 'function', 'function_import', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'match', 'new', 'open_tag_with_echo', 'php_open', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'throw', 'trait', 'try', 'use', 'use_lambda', 'use_trait', 'var', 'while', 'yield', 'yield_from']``
Allowed values: a subset of ``['abstract', 'as', 'attribute', 'break', 'case', 'catch', 'class', 'clone', 'const', 'const_import', 'continue', 'do', 'echo', 'else', 'elseif', 'extends', 'final', 'finally', 'for', 'foreach', 'function', 'function_import', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'match', 'named_argument', 'new', 'open_tag_with_echo', 'php_open', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'throw', 'trait', 'try', 'use', 'use_lambda', 'use_trait', 'var', 'while', 'yield', 'yield_from']``

Default value: ``['abstract', 'as', 'attribute', 'break', 'case', 'catch', 'class', 'clone', 'const', 'const_import', 'continue', 'do', 'echo', 'else', 'elseif', 'extends', 'final', 'finally', 'for', 'foreach', 'function', 'function_import', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'match', 'new', 'open_tag_with_echo', 'php_open', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'throw', 'trait', 'try', 'use', 'use_lambda', 'use_trait', 'var', 'while', 'yield', 'yield_from']``
Default value: ``['abstract', 'as', 'attribute', 'break', 'case', 'catch', 'class', 'clone', 'const', 'const_import', 'continue', 'do', 'echo', 'else', 'elseif', 'extends', 'final', 'finally', 'for', 'foreach', 'function', 'function_import', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'match', 'named_argument', 'new', 'open_tag_with_echo', 'php_open', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'throw', 'trait', 'try', 'use', 'use_lambda', 'use_trait', 'var', 'while', 'yield', 'yield_from']``

Examples
--------
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/FunctionNotation/NoUselessSprintfFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public function isRisky()
/**
* {@inheritdoc}
*
* Must run before MethodArgumentSpaceFixer, NativeFunctionCasingFixer, NoExtraBlankLinesFixer, NoSpacesInsideParenthesisFixer.
* Must run before MethodArgumentSpaceFixer, NativeFunctionCasingFixer, NoEmptyStatementFixer, NoExtraBlankLinesFixer, NoSpacesInsideParenthesisFixer.
*/
public function getPriority()
{
return 3;
return 27;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ final class SingleSpaceAfterConstructFixer extends AbstractFixer implements Conf
'insteadof' => T_INSTEADOF,
'interface' => T_INTERFACE,
'match' => null,
'named_argument' => CT::T_NAMED_ARGUMENT_COLON,
'new' => T_NEW,
'open_tag_with_echo' => T_OPEN_TAG_WITH_ECHO,
'php_open' => T_OPEN_TAG,
Expand Down
1 change: 1 addition & 0 deletions src/Fixer/Semicolon/NoEmptyStatementFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function getDefinition()
* {@inheritdoc}
*
* Must run before BracesFixer, CombineConsecutiveUnsetsFixer, MultilineWhitespaceBeforeSemicolonsFixer, NoExtraBlankLinesFixer, NoSinglelineWhitespaceBeforeSemicolonsFixer, NoTrailingWhitespaceFixer, NoUselessElseFixer, NoUselessReturnFixer, NoWhitespaceInBlankLineFixer, ReturnAssignmentFixer, SpaceAfterSemicolonFixer, SwitchCaseSemicolonToColonFixer.
* Must run after NoUselessSprintfFixer.
*/
public function getPriority()
{
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public function provideFixersPriorityCases()
[$fixers['no_useless_return'], $fixers['no_whitespace_in_blank_line']],
[$fixers['no_useless_sprintf'], $fixers['method_argument_space']],
[$fixers['no_useless_sprintf'], $fixers['native_function_casing']],
[$fixers['no_useless_sprintf'], $fixers['no_empty_statement']],
[$fixers['no_useless_sprintf'], $fixers['no_extra_blank_lines']],
[$fixers['no_useless_sprintf'], $fixers['no_spaces_inside_parenthesis']],
[$fixers['nullable_type_declaration_for_default_null_value'], $fixers['no_unreachable_default_argument_value']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3147,5 +3147,10 @@ public function __construct(
public $bar;
}',
];

yield [
'<?php $foo(test: 1);',
'<?php $foo(test: 1);',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Integration of fixers: no_useless_sprintf,no_empty_statement.
--RULESET--
{"no_useless_sprintf": true, "no_empty_statement": true}
--EXPECT--
<?php


--INPUT--
<?php
;sprintf('foo');
8 changes: 0 additions & 8 deletions tests/Test/AbstractFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,6 @@ final public function testFixerDefinitions()
$options = $this->fixer->getConfigurationDefinition()->getOptions();

foreach ($options as $option) {
// @TODO 2.17 adjust fixers to use new casing and deprecate old one
if (\in_array($fixerName, [
'final_internal_class',
'ordered_class_elements',
], true)) {
static::markTestIncomplete(sprintf('Rule "%s" is not following new option casing yet, please help.', $fixerName));
}

static::assertMatchesRegularExpression('/^[a-z_]+[a-z]$/', $option->getName(), sprintf('[%s] Option %s is not snake_case.', $fixerName, $option->getName()));
}
}
Expand Down
12 changes: 11 additions & 1 deletion tests/Tokenizer/Analyzer/GotoLabelAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testGotoLabelAnalyzerTest($source, array $expectedTrue)

public function provideIsClassyInvocationCases()
{
return [
$tests = [
'no candidates' => [
'<?php
$a = \InvalidArgumentException::class;
Expand Down Expand Up @@ -83,5 +83,15 @@ function A(){}
[10],
],
];

foreach ($tests as $index => $test) {
yield $index => $test;
}

if (\PHP_VERSION_ID >= 80000) {
yield [
'<?php array_fill(start_index: 0, num: 100, value: 50);', [],
];
}
}
}

0 comments on commit ae6fcec

Please sign in to comment.