Skip to content

Commit

Permalink
(chore): php cs fixer use config, update docs, run cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
FreakyWizard committed Nov 14, 2024
1 parent f1007f4 commit d4de317
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 60 deletions.
56 changes: 1 addition & 55 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

# PHP CS Fixer can be run by using the composer script `composer format`
Expand All @@ -18,57 +17,4 @@
->exclude('build')
;

return (new Config)
->setFinder($finder)
->setRules([
'@PSR2' => true,
'indentation_type' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha',
],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'logical_operators' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'phpdoc_var_without_name' => true,
'phpdoc_single_line_var_spacing' => true,
'unary_operator_spaces' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'no_superfluous_elseif' => true,
'single_blank_line_before_namespace' => true,
'blank_line_after_opening_tag' => true,
'no_blank_lines_after_phpdoc' => true,
'phpdoc_separation' => true,
'method_chaining_indentation' => true,
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'=>' => null,
'|' => 'no_space',
],
],
'return_type_declaration' => [
'space_before' => 'none',
],
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'full_opening_tag' => true,
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'yoda_style' => [
'always_move_variable' => true,
'equal' => true,
'identical' => true,
'less_and_greater' => true,
],
'declare_strict_types' => true,
])
->setLineEnding("\n")
->setRiskyAllowed(true);
return \Yard\PhpCsFixerRules\Config::create($finder);
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ To install this package using Composer, follow these steps:

## Usage

Simple example:
```php

Check failure on line 33 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Fenced code blocks should be surrounded by blank lines

README.md:33 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```php"] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md031.md
<?php

Expand All @@ -45,10 +46,34 @@ $finder = Finder::create()
->exclude('build')
;

return \Yard\PhpCsFixerRules\Config::setFinder($finder)
->mergeRules([ // allows you to add new rules or override rules from default
'declare_strict_types' => false,
return \Yard\PhpCsFixerRules\Config::create($finder);
```

More complex:
```php

Check failure on line 53 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Fenced code blocks should be surrounded by blank lines

README.md:53 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```php"] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md031.md
<?php

use PhpCsFixer\Finder;

$finder = Finder::create()
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
->exclude('public')
->exclude('node_modules')
->exclude('build')
;

return \Yard\PhpCsFixerRules\Config::create($finder)
->mergeRules([

Check failure on line 70 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:70:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
'yoda_style' => [

Check failure on line 71 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:71:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
'equal' => false,

Check failure on line 72 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:72:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
],

Check failure on line 73 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:73:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
])

Check failure on line 74 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:74:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
->setRiskyAllowed(false) // override and disable risky setting for old projects
->get();
->removeRule('declare_strict_types')

Check failure on line 75 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:75:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
->removeRules(['no_unused_imports', 'trailing_comma_in_multiline'])

Check failure on line 76 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:76:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
->setRiskyAllowed(false); // disable this for old sites!

Check failure on line 77 in README.md

View workflow job for this annotation

GitHub Actions / Markdown Linting

Hard tabs

README.md:77:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md010.md
```

2 changes: 2 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<?php

declare(strict_types=1);

0 comments on commit d4de317

Please sign in to comment.