Skip to content

Commit

Permalink
minor #3377 rules - change default options (keradus)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.0 branch (closes #3377).

Discussion
----------

rules - change default options

Commits
-------

9993d51 rules - change default options
  • Loading branch information
keradus committed Mar 29, 2018
2 parents da49a01 + 9993d51 commit 9b7dfde
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $config = PhpCsFixer\Config::create()
'explicit_string_variable' => true,
'final_internal_class' => true,
'fully_qualified_strict_types' => true,
'function_to_constant' => ['functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi']],
'function_to_constant' => true,
'header_comment' => ['header' => $header],
'heredoc_to_nowdoc' => true,
'list_syntax' => ['syntax' => 'long'],
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ Choose from the list of available rules:
Configuration options:

- ``functions`` (``array``): list of function names to fix; defaults to
``['get_class', 'php_sapi_name', 'phpversion', 'pi']``
``['get_called_class', 'get_class', 'php_sapi_name', 'phpversion', 'pi']``

* **function_typehint_space** [@Symfony]

Expand Down Expand Up @@ -726,7 +726,7 @@ Choose from the list of available rules:
Configuration options:

- ``ensure_fully_multiline`` (``bool``): ensure every argument of a multiline
argument list is on its own line; defaults to ``false``
argument list is on its own line; defaults to ``true``
- ``keep_multiple_spaces_after_comma`` (``bool``): whether keep multiple spaces
after comma; defaults to ``false``

Expand Down Expand Up @@ -1047,7 +1047,7 @@ Choose from the list of available rules:
Configuration options:

- ``target`` (``'3.0'``, ``'3.5'``, ``'5.0'``, ``'5.6'``, ``'newest'``): target version of
PHPUnit; defaults to ``'5.0'``
PHPUnit; defaults to ``'newest'``

* **php_unit_expectation** [@PHPUnit52Migration:risky, @PHPUnit54Migration:risky, @PHPUnit55Migration:risky, @PHPUnit56Migration:risky, @PHPUnit57Migration:risky, @PHPUnit60Migration:risky]

Expand Down Expand Up @@ -1160,8 +1160,8 @@ Choose from the list of available rules:

Configuration options:

- ``tags`` (``array``): the tags that should be aligned; defaults to ``['param',
'return', 'throws', 'type', 'var']``
- ``tags`` (``array``): the tags that should be aligned; defaults to ``['method',
'param', 'property', 'return', 'throws', 'type', 'var']``

* **phpdoc_annotation_without_dot** [@Symfony]

Expand Down
9 changes: 9 additions & 0 deletions UPGRADE-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ Rule | Option | Change
`is_null` | `use_yoda_style` | option was removed, use `yoda_style` rule instead
`no_extra_consecutive_blank_lines` | `tokens` | one of possible values, `useTrait`, was renamed to `use_trait`
`php_unit_dedicate_assert` | `functions` | option was removed, use `target` instead

### Changed default values of options

Rule | Option | Old value | New value
---- | ---- | ---- | ----
`function_to_constant` | `functions` | `['get_class', 'php_sapi_name', 'phpversion', 'pi']` | `['get_called_class', 'get_class', 'php_sapi_name', 'phpversion', 'pi']`
`method_argument_space` | `ensure_fully_multiline` | `false` | `true`
`php_unit_dedicate_assert` | `target` | `5.0` | `newest`
`phpdoc_align` | `tags` | `['param', 'return', 'throws', 'type', 'var']` | `['method', 'param', 'property', 'return', 'throws', 'type', 'var']`
2 changes: 1 addition & 1 deletion src/Fixer/Basic/NonPrintableCharacterFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function createConfigurationDefinition()
return new FixerConfigurationResolver([
(new FixerOptionBuilder('use_escape_sequences_in_strings', 'Whether characters should be replaced with escape sequences in strings.'))
->setAllowedTypes(['bool'])
->setDefault(false) // @TODO 3.0 change to true
->setDefault(false) // @TODO 3.0 consider changing to true, but it will require that all fixed code by default is php7+, maybe the best is to keep it in `@PHP70Migration:risky` only
->setNormalizer(static function (Options $options, $value) {
if (PHP_VERSION_ID < 70000 && $value) {
throw new InvalidOptionsForEnvException('Escape sequences require PHP 7.0+.');
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/FunctionNotation/MethodArgumentSpaceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public function getDefinition()
),
new CodeSample(
"<?php\nfunction sample(\$a=10,\n \$b=20,\$c=30) {}\nsample(1,\n 2);\n",
['ensure_fully_multiline' => true]
['ensure_fully_multiline' => false]
),
new CodeSample(
"<?php\nfunction sample(\$a=10,\n \$b=20,\$c=30) {}\nsample(1, \n 2);\nsample('foo', 'foobarbaz', 'baz');\nsample('foobar', 'bar', 'baz');\n",
[
'ensure_fully_multiline' => true,
'ensure_fully_multiline' => false,
'keep_multiple_spaces_after_comma' => true,
]
),
Expand Down Expand Up @@ -118,7 +118,7 @@ protected function createConfigurationDefinition()
'Ensure every argument of a multiline argument list is on its own line'
))
->setAllowedTypes(['bool'])
->setDefault(false) // @TODO 3.0 should be true
->setDefault(true)
->getOption(),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/LanguageConstruct/FunctionToConstantFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ protected function createConfigurationDefinition()
(new FixerOptionValidatorGenerator())->allowedValueIsSubsetOf($functionNames),
])
->setDefault([
'get_called_class',
'get_class',
'php_sapi_name',
'phpversion',
'pi',
// TODO on v3.0 add 'get_called_class' here
])
->getOption(),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected function createConfigurationDefinition()
PhpUnitTargetVersion::VERSION_5_6,
PhpUnitTargetVersion::VERSION_NEWEST,
])
->setDefault(PhpUnitTargetVersion::VERSION_5_0) // @TODO 3.x: change to `VERSION_NEWEST`
->setDefault(PhpUnitTargetVersion::VERSION_NEWEST)
->getOption(),
]);
}
Expand Down
6 changes: 2 additions & 4 deletions src/Fixer/Phpdoc/PhpdocAlignFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,10 @@ protected function createConfigurationDefinition()
->setAllowedValues([
$generator->allowedValueIsSubsetOf(self::$alignableTags),
])
/*
* By default, all tags apart from @property and @method will be aligned for backwards compatibility
* @TODO 3.0 Align all available tags by default
*/
->setDefault([
'method',
'param',
'property',
'return',
'throws',
'type',
Expand Down
21 changes: 6 additions & 15 deletions src/RuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class RuleSet implements RuleSetInterface
'line_ending' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'method_argument_space' => ['ensure_fully_multiline' => true],
'method_argument_space' => true,
'no_break_comment' => true,
'no_closing_tag' => true,
'no_spaces_after_function_name' => true,
Expand Down Expand Up @@ -75,7 +75,9 @@ final class RuleSet implements RuleSetInterface
'increment_style' => true,
'lowercase_cast' => true,
'magic_constant_casing' => true,
'method_argument_space' => true,
'method_argument_space' => [
'ensure_fully_multiline' => false,
],
'native_function_casing' => true,
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
Expand Down Expand Up @@ -109,18 +111,7 @@ final class RuleSet implements RuleSetInterface
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'php_unit_fqcn_annotation' => true,
'phpdoc_align' => [
// @TODO: on 3.0 switch whole rule to `=> true`, currently we use custom config that will be default on 3.0
'tags' => [
'method',
'param',
'property',
'return',
'throws',
'type',
'var',
],
],
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
Expand Down Expand Up @@ -163,7 +154,7 @@ final class RuleSet implements RuleSetInterface
'@Symfony:risky' => [
'dir_constant' => true,
'ereg_to_preg' => true,
'function_to_constant' => true,
'function_to_constant' => ['functions' => ['get_class', 'php_sapi_name', 'phpversion', 'pi']], // @TODO: consider changing to true
'is_null' => true,
'modernize_types_casting' => true,
'no_alias_functions' => true,
Expand Down
Loading

0 comments on commit 9b7dfde

Please sign in to comment.