The following code requires no change on windows and fails on linux:
Windows 10, PHP v. 5.6.25, php-cs-fixer v. 2.4.0
/**
* Desc here
*
* @param array $xyz Desc here
*
* @return array Array of data.
* [
* [
* 'id' => 1,
* 'qty_ordered' => 2,
* 'Product' => [
* 'id' => 1,
* 'name' => 'xxxx',
* ],
* ],
* ]
*/
function foo(array $xyz)
{
//
}
On linux (several flavors) it does this ugly fix:
Amazon Linux AMI release 2016.09, PHP v. 5.6.29, php-cs-fixer v. 2.4.0
/**
* Desc here
*
* @param array $xyz Desc here
*
* @return array Array of data.
* [
* [
* 'id' => 1,
* 'qty_ordered' => 2,
* 'BaseProduct' => [
* 'id' => 1,
* 'name' => 'xxxx',
* ],
* ],
* ]
*/
function foo(array $xyz)
{
//
}
Ran the fixer using vendors/bin/php-cs-fixer fix <filename>
My configuration:
return PhpCsFixer\Config::create()
->setIndent("\t")
->setLineEnding(PHP_EOL)
->setUsingCache(false)
->setRules([
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true],
'blank_line_after_namespace' => true,
'blank_line_before_return' => true,
// 'braces' => true,
// 'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'elseif' => true,
'full_opening_tag' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'line_ending' => true,
'lowercase_cast' => true,
'lowercase_keywords' => true,
'method_argument_space' => true,
// 'method_separation' => true,
'native_function_casing' => true,
// 'new_with_braces' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
// 'no_useless_else' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
// 'ordered_class_elements' => true,
'ordered_imports' => true,
// 'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_order' => true,
'phpdoc_separation' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'single_class_element_per_statement' => true,
'standardize_not_equals' => true,
'trim_array_spaces' => true,
'visibility_required' => true,
])
->setFinder($finder)
;
Thanks for report.
Sadly, we can not proceed with it.
Please provide all the data you were requested:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.4/.github/ISSUE_TEMPLATE
@keradus Edited with more info
Thanks @josephzidell ,
sorry to ask but can you provide a little bit more?
We need to know the PHP version(s) used and the version of PHP CS Fixer itself, please provide OS details and the configuration used for the fixer if this is relevant to replicate the issue.
Currently I've no Windows (vm) box @ hand, maybe a unit tests can be made out of your example? We run the tests on Linux, Windows and Mac using Travis so the issue should be come visible when PR'ed as unit test.
@SpacePossum Edited with more info. Is there any more info beyond that, that I could possibly give you?
looks quite nice now ;)
now we will probably need some time to investigate it
To me (an outsider) it seems that the line immediately following a @return is considered part of the annotation on Linux, while considered separate on Windows. A blank line between solves all problems.
Some findings, Ubuntu with fixer @ master this is done by the phpdoc_align fixer.
(damn, the history of that fixer, the authors and regex magic, wow : D)
@SpacePossum That's in the title 馃槃
I should mention that this also doesn't work:
/**
* Desc here
*
* @param array $xyz Desc here
*
* @return array Array of data.
* [
* [
* 'id' => 1,
* 'qty_ordered' => 2,
* 'Product' => [
* 'id' => 1,
* 'name' => 'xxxx',
* ],
* ],
* ]
*/
function foo(array $xyz)
{
//
}
@SpacePossum Bringing this to the forefront again
Thanks @jonathaningram
I've been updating this test for some time now;
prove issue on 2.2:
https://github.com/SpacePossum/PHP-CS-Fixer/commit/0b464c2d405f7a8ffa644de8e168261a7d2b0fd5
I've been busy on some other issues etc. lately so sadly didn't solve it. I do find it important to fix it, though there is a lot of regex code being involved that still try to grasp fully before I can resolve the issue at hand.
Hope to work on a fix soon, any help welcome (hint at all contributors/members)!
Most helpful comment
@SpacePossum That's in the title 馃槃