-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
PHP CS Fix #216
PHP CS Fix #216
Conversation
This PR related to #215 |
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
=========================================
Coverage 93.26% 93.26%
Complexity 466 466
=========================================
Files 77 77
Lines 1425 1425
=========================================
Hits 1329 1329
Misses 96 96
Continue to review full report at Codecov.
|
Hi, can I get your cs settings or script? There are few corrections I have to make. |
<?php
declare(strict_types=1);
return PhpCsFixer\Config::create()
->setCacheFile(__DIR__ . '/php_cs.cache')
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'trailing_comma_in_multiline_array' => false,
'native_constant_invocation' => false,
'native_function_invocation' => false,
'protected_to_private' => false,
'no_alias_functions' => false,
'set_type_to_cast' => false,
'phpdoc_inline_tag' => false,
'function_to_constant' => false,
'self_accessor' => false,
'increment_style' => false,
'phpdoc_var_without_name' => false,
'binary_operator_spaces' => [
'default' => 'align',
],
'array_syntax' => [
'syntax' => 'short',
],
'is_null' => false,
'cast_spaces' => [
'space' => 'none',
],
'declare_strict_types' => true,
'ordered_imports' => [
'sortAlgorithm' => 'alpha',
'importsOrder' => [
'const',
'function',
'class',
],
],
'no_useless_else' => true,
'no_useless_return' => true,
'php_unit_construct' => true,
'php_unit_strict' => true,
'phpdoc_separation' => false,
'concat_space' => [
'spacing' => 'one'
],
'phpdoc_align' => [
'tags' => []
],
'phpdoc_annotation_without_dot' => true,
'phpdoc_no_alias_tag' => false,
'yoda_style' => false,
'phpdoc_to_comment' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude([
'vendor',
'bin',
'tests',
])
->notPath('functions.php')
); |
@wolfy-j I followed https://cs.symfony.com/ and created |
To avoid changing too many code styles, I disabled some rules, although I think they make sense. |
Thank you, considering the impact and 60+ repos we have to apply to I can't guarantee quick merge. I need to talk to all the teams to make sure that CS is aligned. |
FYI, we did not forget about it, @alexndr-novikov is working on the full-size analysis of the best approach. |
Thank you for your excellent work. 👍 |
Thank you @charescape , we highly appreciate your contribution. Unfortunately, this PR requires some modifications to be merged. It does not fit PSR-12, and has some changes that are not required by it, but do some unnecessary code changes. (like php-cs-fix 'binary_operator_spaces' alignment with '=' sign and etc.) These's one problem : php-cs-fixer does not support PSR-12 yet (it is expected in v3, PHP-CS-Fixer/PHP-CS-Fixer#4502), so now you'll need 2 tools to fix the code in proper way and check it: code sniffer that already supports PSR-12 checks, and PHP-CS-Fixer. So, please follow the instruction to update this PR (or optionally close this one, re-fork and apply from scratch and then create new one)
<?php
declare(strict_types=1);
return PhpCsFixer\Config::create()
->setCacheFile(__DIR__ . '/.php_cs.cache')
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'binary_operator_spaces' => [
'default' => null,
'operators' => [
'|' => 'single_space',
'!==' => 'single_space',
'!=' => 'single_space',
'==' => 'single_space',
'===' => 'single_space',
]
],
'ordered_class_elements' => true,
'trailing_comma_in_multiline_array' => false,
'declare_strict_types' => true,
'linebreak_after_opening_tag' => true,
'blank_line_after_opening_tag' => true,
'single_quote' => true,
'lowercase_cast' => true,
'short_scalar_cast' => true,
'no_leading_import_slash' => true,
'declare_equal_normalize' => [
'space' => 'none'
],
'new_with_braces' => true,
'no_blank_lines_after_phpdoc' => true,
'single_blank_line_before_namespace' => true,
'visibility_required' => ['property', 'method', 'const'],
'ternary_operator_spaces' => true,
'unary_operator_spaces' => true,
'return_type_declaration' => true,
'concat_space' => [
'spacing' => 'one'
],
'no_useless_else' => true,
'no_useless_return' => true,
'phpdoc_separation' => false,
'yoda_style' => false,
'void_return' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude([
'vendor',
'bin',
])
);
If last check still alert any issues (usually about class docblock and declare order and blank lines) - fix it manually please
vendor/bin/phpcs -n --report=code --standard=PSR12 --colors tests src And then update the pull request. Let me know if you have any questions about it |
@alexndr-novikov Thank you very much. I am going to follow your instruction and update this PR soon. |
done.
done.
done.
done.
done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost perfect, need a minor change in .travis.yml, commented it separately
Hi, we have implemented your standards as separate package. Unfortunately, it now causes conflicts on this merge. I'll close it. |
@charescape if you want you can use spiral/code-style by yourself, so the PR will remain after you. |
@charescape |
@wolfy-j Thank you! I will try to update this PR today. |
I'll push an update with enabled CS to it. Travis will fail for now, so we will see how the CS will work. |
@charescape
|
@alexndr-novikov Thanks for your instruction. I will do it soon. |
Hi, we are prepping big release, when do you think we can merge it? :| |
@wolfy-j @alexndr-novikov Sorry, I'm still busy at the moment, and I don't want to delay the progress of your project, so this PR should be closed. |
Sorry about that. |
No description provided.