Skip to content

Commit

Permalink
upgrade to php-cs-fixer v3
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed Jun 1, 2021
1 parent 669260e commit 6d8882a
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 21 deletions.
11 changes: 11 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
require_once(__DIR__.'/vendor/autoload.php');

use Permafrost\PhpCsFixerRules\Finders\ComposerPackageFinder;
use Permafrost\PhpCsFixerRules\Rulesets\DefaultRuleset;
use Permafrost\PhpCsFixerRules\SharedConfig;

// optional: chain additiional custom Finder options:
$finder = ComposerPackageFinder::create(__DIR__);

return SharedConfig::create($finder, new DefaultRuleset());
File renamed without changes.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"symfony/console": "^5.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"friendsofphp/php-cs-fixer": "^3.0",
"phpunit/phpunit": "^9.4"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function prepareItems(array $items, array $excludeItems): array

return Collection::create($items)
->exclude($excludeItems)
->filter(function ($item) {
->filter(function($item) {
return !Str::startsWith($item, '.');
})
->values()
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Support/CustomConfigGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public function setPaths($includePaths, $excludePaths)
public function generateFinderCode(): string
{
$includeCode = trim(Collection::create($this->includePaths)
->map(function ($item) {
->map(function($item) {
return " __DIR__ . '/$item',";
})
->implode(PHP_EOL));

$excludeCode = Collection::create($this->excludePaths)
->map(function ($item) {
->map(function($item) {
return " ->notPath('$item/*')";
})
->implode(PHP_EOL);
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Support/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct($input)
$this->initialize();
}

protected function initialize(string $defaultFilename = '.php_cs.dist'): void
protected function initialize(string $defaultFilename = '.php-cs-fixer.dist.php'): void
{
$this->filename = $this->input->hasOption('outfile')
? $this->input->getOption('outfile')
Expand Down
2 changes: 1 addition & 1 deletion src/Finders/BaseFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abstract class BaseFinder
{
public static function onlyExistingPaths(array $paths): array
{
return array_filter($paths, function ($path) {
return array_filter($paths, function($path) {
return file_exists($path) && is_dir($path);
});
}
Expand Down
12 changes: 5 additions & 7 deletions src/Rulesets/DefaultRuleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static function name(): string
public function rules(): array
{
return array_merge([
'psr0' => false,
'@PSR2' => true,
'@Symfony' => true,
'array_syntax' => [
Expand All @@ -44,16 +43,15 @@ public function rules(): array
'closure_function_spacing' => 'none',
],
'increment_style' => [
'style' => 'post'
'style' => 'post',
],
'indentation_type' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'lowercase_constants' => false,
'lowercase_keywords' => true,
'method_argument_space' => [
'ensure_fully_multiline' => true,
],
//'method_argument_space' => [
// 'ensure_fully_multiline' => true,
//],
'no_break_comment' => false,
'no_closing_tag' => true,
'no_spaces_after_function_name' => true,
Expand All @@ -64,7 +62,7 @@ public function rules(): array
'no_unused_imports' => true,
'not_operator_with_successor_space' => false,
'ordered_imports' => [
'sortAlgorithm' => 'alpha',
'sort_algorithm' => 'alpha',
],
'phpdoc_align' => [
'align' => 'left',
Expand Down
8 changes: 5 additions & 3 deletions src/Rulesets/LaravelShiftRuleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function rules(): array
'concat_space' => [
'spacing' => 'none',
],
'constant_case' => ['case' => 'lower'],
'declare_equal_normalize' => true,
'elseif' => true,
'encoding' => true,
Expand All @@ -55,7 +56,6 @@ public function rules(): array
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true, // added from Symfony
'magic_method_casing' => true, // added from Symfony
Expand Down Expand Up @@ -104,7 +104,7 @@ public function rules(): array
'object_operator_without_whitespace' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
//'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
Expand Down Expand Up @@ -133,7 +133,9 @@ public function rules(): array
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => [
'elements' => ['arrays'],
],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Rulesets/PhpUnitRuleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function rules(): array
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'echo_tag_syntax' => ['format' => 'long'],
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
Expand Down
4 changes: 3 additions & 1 deletion src/Rulesets/SpatieRuleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public function rules(): array
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => [
'elements' => ['arrays'],
],
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function push(...$items): self

public function exclude(array $items): self
{
return $this->filter(function ($value) use ($items) {
return $this->filter(function($value) use ($items) {
return !in_array($value, $items);
})->values();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function getSubDirectoryNames(string $path, array $excludeNames =
return Collection::create($files)
->exclude(['.', '..'])
->exclude($excludeNames)
->filter(function ($item) {
->filter(function($item) {
return is_dir($item);
})
->values();
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function afterLast(string $value, string $after): string
if ($offset === false) {
$offset = 0;
} else {
++$offset;
$offset++;
}

return substr($value, $offset);
Expand Down

0 comments on commit 6d8882a

Please sign in to comment.