Skip to content

SelfUpdateCommand updates to non-stable version #1925

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

Closed
Hariador opened this issue May 27, 2016 · 8 comments
Closed

SelfUpdateCommand updates to non-stable version #1925

Hariador opened this issue May 27, 2016 · 8 comments

Comments

@Hariador
Copy link

The currently hosted phar does not run.

jon@jon-bold-mac:~/repo$ php php-cs-fixer2 fix ./back-end/
PHP Fatal error: Class 'Symfony\CS\Finder\DefaultFinder' not found in /home/jon/repo/back-end/.php_cs on line 3

Here's the contents of our .php_cs file.

exclude('config','storage','bootstrap') ->in(**DIR**); return Symfony\CS\Config\Config::create() ->fixers(array('trailing_spaces','-psr0')) ->finder($finder);
@GrahamCampbell
Copy link
Contributor

That's because you are using the 2.x version. You need to use 1.x if you want that file.

@GrahamCampbell
Copy link
Contributor

@Hariador
Copy link
Author

Sorry, the '2' was just added by me while I was saving the .phar.
curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer
is what I ran to get it.

And I assume by "that file" you're referring to .php_cs?

@gharlan
Copy link
Contributor

gharlan commented May 27, 2016

The currently hosted phar does not run.

There is a mistake on http://cs.sensiolabs.org. It is 2.0-dev but should be 1.x.

@keradus keradus changed the title php-cs-fixed.phar contains broken Symphony libraries. SelfUpdateCommand updates to non-stable version Jun 4, 2016
@keradus
Copy link
Member

keradus commented Jun 4, 2016

ref #1956

@keradus keradus closed this as completed in 7817c3b Jun 7, 2016
@keradus
Copy link
Member

keradus commented Jun 7, 2016

If sb have updated to 2.0.0-alpha and want to rollback he should run self-update once again, he will get latest stable 1.11.4

@zmorris
Copy link

zmorris commented Dec 12, 2016

As #1925 and #1953 are the first links in google for:

Fatal error: Class 'Symfony\CS\Finder\DefaultFinder' not found

I thought I'd post the fix. This problem is due to upgrading from PHP-CS-Fixer 1.x to 2.x which had a breaking change from Symfony\CS to PhpCsFixer. Also note that according to https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md#config-file PHP-CS-Fixer 2.x should use .php_cs.dist so that users can customize their project's default config with their own .php_cs. Here is my updated config that works with either version and is compatible with Laravel 5.x:

.php_cs.dist:

<?php

// for more info see:
// https://github.com/FriendsOfPHP/PHP-CS-Fixer#usage
// https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md

if (class_exists('PhpCsFixer\Finder')) {    // PHP-CS-Fixer 2.x
    $finder = PhpCsFixer\Finder::create()
        ->in(__DIR__)
    ;

    return PhpCsFixer\Config::create()
        ->setRules(array(
            '@PSR2' => true,
        ))
        ->setFinder($finder)
    ;
}

.php_cs:

<?php

// for more info see:
// https://github.com/FriendsOfPHP/PHP-CS-Fixer#usage
// https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md

if (class_exists('PhpCsFixer\Finder')) {    // PHP-CS-Fixer 2.x
    $finder = PhpCsFixer\Finder::create()
        ->in(__DIR__)
    ;

    return PhpCsFixer\Config::create()
        ->setRules(array(
            '@PSR2' => true,
        ))
        ->setFinder($finder)
    ;
} elseif (class_exists('Symfony\CS\Finder\DefaultFinder')) {  // PHP-CS-Fixer 1.x
    $finder = Symfony\CS\Finder\DefaultFinder::create()
        ->in(__DIR__)
    ;

    return Symfony\CS\Config\Config::create()
        ->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
        ->fixers(['-psr0'])    // don't lowercase namespace (use "namespace App\.." instead of "namespace app\..") to be compatible with Laravel 5
        ->finder($finder)
    ;
}

.gitignore

/vendor
/node_modules
.env
.DS_Store
.php_cs

@keradus
Copy link
Member

keradus commented Dec 12, 2016

I would not advise to use 2 versions at same time. they were many bc breakers and for that not only config is different, but the behaviour of tool itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants