hi,I have a question
to config function_declaration option
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/function_notation/function_declaration.rst
this option allowed values: 'none', 'one'
so try this like
php ./vendor/bin/php-cs-fixer fix ./fileupload/test.php --diff --rules='{"function_declaration":{"closure_function_spacing":"none"}}' -vv --dry-run
php ./vendor/bin/php-cs-fixer fix ./fileupload/test.php --diff --rules='{"function_declaration":{"closure_function_spacing":"one"}}' -vv --dry-run
but same result like
-function someEx ($someParam) {
+function someEx($someParam) {
I want to have a space in function_declaration
how to do that?
--rules=@Symfony,-@PSR1,-blank_line_before_statement,php_unit_method_casing --verbose fix $FileDir$/$FileName$
I'm looking at the changeset generated by this tool and wonder whether certain formatting options related to assignment alignment from PHPStorm are available as well:
$this->state->pConnection = DriverManager::getConnection([
- 'url' => $connectionString,
- 'password' => $password,
+ 'url' => $connectionString,
+ 'password' => $password,
'driverOptions' => $driverOptions,
- 'charset' => 'UTF8',
+ 'charset' => 'UTF8',
], $configuration);
As you can see the original alignment has been removed, while that one improves readability in my opinion. Is there any way to achieve the same result with php-cs-fixer without implementing a custom rule?
doc/rules/index.rst: Enforce camel (or snake) case for PHPUnit test methods, following configuration.
phpmd.xml: <rule ref="rulesets/controversial.xml/CamelCaseClassName" />
phpmd.xml: <rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
phpmd.xml: <rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
phpmd.xml: <rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
phpmd.xml: <rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
```PHP Warning: Module 'ast' already loaded in Unknown on line 0
Description of the @PSR12:risky set.
Rules that follow PSR-12 (https://www.php-fig.org/psr/psr-12/) standard.
This set contains risky rules.
no_trailing_whitespace_in_string risky
| There must be no trailing whitespace in strings.
no_unreachable_default_argument_value risky
| In function arguments there must not be arguments with default values before non-default ones.
```
hey, I'm currently chasing a bug in php-cs-fixer
I have following config excluding a file with a syntax error:
$finder = PhpCsFixer\Finder::create()
->exclude(__DIR__ . '/tests/data/Invalid.php')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->append([__FILE__]);
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
])->setFinder($finder);
but I get an error that the excluded file have invalid syntax (which is on purpose)
do I use the $finder
in a wrong way or is it currently not possible to ignore/exclude invalid syntax files?
exclude
is only for directories, you can try ->notName
, the docs for Symfony Finder are here https://symfony.com/doc/current/components/finder.html with examples
--using-cache
\Foo\Bar\Baz
to a short version + a use
statement? I can't seem to find any. The GlobalNamespaceImportFixer only does it for global classes. Thanks in advance!
'@PHP74Migration' => true,
'@PHP74Migration:risky' => false,
'@PHPUnit84Migration:risky' => false,
'@PSR12' => true,
'@PhpCsFixer' => true,
'function_declaration' => ['closure_function_spacing' => 'none'],
'blank_line_after_namespace' => true,
'class_attributes_separation' => [
'elements' => [
'const' => 'one',
'method' => 'one',
'property' => 'one',
],
],
'declare_strict_types' => true,
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'arrays']],
'increment_style' => ['style' => 'post'],
'binary_operator_spaces' => ['align_double_arrow' => false],
'phpdoc_align' => ['align' => 'left'],
'trim_array_spaces' => true,
'no_trailing_comma_in_singleline_array' => true,
'ordered_class_elements' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'phpunit',
'magic',
'method_public',
'method_protected',
'method_private',
],
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']],
'concat_space' => ['spacing' => 'one'],
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
'whitespace_after_comma_in_array' => true,
'cast_spaces' => true,
'yoda_style' => false,
Hi, maybe anyone had a problem with binary_operator_spaces. Yesterday it broke. I don`t know why.
I have this config:
'binary_operator_spaces' => [
'description' => 'Binary operators should be surrounded by space as configured',
'config' => [
'default' => null,
'operators' => [
'=>' => 'align_single_space',
'=' => 'align_single_space',
'&=' => 'align_single_space',
And before broke this code was error:
$aSort = $a['SORT'] ?? null;
$bSort = $b['SORT'] ?? null;
$aID = $a['LESSON_ID'] ?? null;
$bID = $b['LESSON_ID'] ?? null;
$aSort = TypeCaster::int($aSort);
$bSort = TypeCaster::int($bSort);
$aID = TypeCaster::int($aID);
$bID = TypeCaster::int($bID);
But now PhpCsFixer does not see mistaken formatting