Php-cs-fixer: Error while using binary_operator_spaces

Created on 22 Jan 2017  路  15Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

Each time I want set align_double_arrow or align_equals to true in my .php_cs, I got an error:

Loaded config default from "/var/www/project/.php_cs".
E
Legend: ?-unknown, I-invalid file syntax, file ignored, S-Skipped, .-no changes, F-fixed, E-error

Fixed all files in 0.013 seconds, 6.000 MB memory used

Files that were not fixed due to errors reported during fixing:
   1) /var/www/project/CSTestController.php

With this file https://gist.github.com/AntoineLemaire/d8153d17fca3b1e67ef2dc98810180b3

And this .php_cs

<?php

return PhpCsFixer\Config::create()
    ->setUsingCache(false)
    ->setRules(array(
        '@Symfony' => true,
        'array_syntax' => array('syntax' => 'short'),
        'unalign_equals' => false,
        'phpdoc_order' => true,
        'phpdoc_to_comment' => false,
        'binary_operator_spaces' => array(
            'align_double_arrow' => true,
            'align_equals' => true,
        ),
    ))
;

I'm using php 7.0.13

PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies

and php-cs-fixer 2.0.0

php-cs-fixer -vvv fix /var/www/project/CSTestController.php

Most helpful comment

Thanks for reporting back!
I took a look at the change log between 7.0.13 and .15-1 and nothing popped out to me what might have fixed the issue. Therefor I'm not sure how to proceed here, bug hunt for 7.0.13 or let it go in fav. of people updating to .15-1 (or up).
One thing that we could do anyway is improving the error/exception reporting of the tool, which has been requested a few times, really hope to find some time for that.

All 15 comments

I failed to reproduce the error with a checkout version @ v2.0.0 using PHP 7.1.0-5+deb.sury.org~xenial+1 (cli) ( NTS ) on Ubuntu 16.04.1 LTS. Anyone else got time to help out?

@AntoineLemaire , would it be fine for you to reveal the /var/www/project/CSTestController.php file content ?

He did, see the link to the gist ;)

ah, sorry

It's working with PHP 7.0.15-1

PHP 7.0.15-1+deb.sury.org~xenial+1 (cli) (built: Jan 20 2017 08:53:13) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15-1+deb.sury.org~xenial+1, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

Thanks for reporting back!
I took a look at the change log between 7.0.13 and .15-1 and nothing popped out to me what might have fixed the issue. Therefor I'm not sure how to proceed here, bug hunt for 7.0.13 or let it go in fav. of people updating to .15-1 (or up).
One thing that we could do anyway is improving the error/exception reporting of the tool, which has been requested a few times, really hope to find some time for that.

I got the same bug.
php version: PHP 7.0.16-3+deb.sury.org~xenial+1 (cli) (built: Feb 22 2017 10:05:52) ( NTS )

thanks @kcloze for reporting!

proposed solution @ https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/2556#issuecomment-282239409 @keradus how would you like to deal this?

require symfony/polyfill-xml, suggest ext-xml

The configure with binary_operator_spaces is ok?

@kcloze I think it is ok, does it not work for you?

it's not working.

            'binary_operator_spaces' => [
               'align_double_arrow' => true,
               'align_equals'       => true,
            ],

align_equals not working,for example:

image

I used input

<?php
$params = [
    'code' => $code,
    'message' => $message,
    'timeStamp' => time(),
    'content' => $content,
];

output:

<?php
$params = [
    'code'      => $code,
    'message'   => $message,
    'timeStamp' => time(),
    'content'   => $content,
];

config:

  'binary_operator_spaces' => [
               'align_double_arrow' => true,
               'align_equals'       => true,
            ],

so this works for 2.1 for me.

Thanks @kcloze , this seems another issue with the fixer (this/first one was missing requirements).
Maybe you can report this as a new issue?
We would need code that you are fixing and the result (in text form, not screenshot pref. so people can copy-paste it).
The full configuration you use and/or command you run from the commandline.
PHP and PHP-CS-Fixer versions.

Sorry,I finded that it's working with vim editor,but not working in the vscode editor.
then, I changed vscode editor.fontFamily,it's ok!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vitek-rostislav picture vitek-rostislav  路  3Comments

grachevko picture grachevko  路  3Comments

datenmeister picture datenmeister  路  3Comments

BackEndTea picture BackEndTea  路  3Comments

carusogabriel picture carusogabriel  路  3Comments