-
Notifications
You must be signed in to change notification settings - Fork 701
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
sllh/php-cs-fixer-styleci-bridge v2.1 upgrade #1523
sllh/php-cs-fixer-styleci-bridge v2.1 upgrade #1523
Conversation
I don't think that we need to support both versions as the CS fixer is only required as a dev dependency. |
PHP-CS-Fixer is not required at project level dependencies and user can use both version ATM. |
@@ -1,6 +1,6 @@ | |||
<?php | |||
|
|||
require_once './vendor/autoload.php'; | |||
require __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php'; |
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.
Isn't it enough to load composer ?
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.
You might have some common library conflict with the composer autoload.
See: https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge#troubleshooting
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.
@soullivaneuh your autoloader doesn't fix anything (seldaek proposed a solution in composer/composer#1493 to automatically call the __static
method of every objects loaded which is not what you tried to fix in puli/cli#21).
Whatever is the solution it is not this one, so should be reverted ;)
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.
You mean this solution? composer/composer#1493 (comment)
AFAIK, this is exactly what I did: https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge/blob/v2.1.1/autoload.php#L32-L34
And this solve the issue I got on Puli.
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.
@soullivaneuh except that your bridge does not have anything with a __static
method needing to be called when the class is loaded. This was the specific need asked in this github issue, not a requirement when writing custom autoloaders.
And your "custom" autoloader will not prevent library conflicts, as it will still delegate calls to the composer autoloader for any class, meaning it will still load everything.
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.
If you have better to propose to fix issue like puli/cli#21, I'm hearing because this is the only thing I found so far.
As this library is not concerned yet, I'll revert this part for now.
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.
@soullivaneuh maybe the conflict wasn't longer here but the aim of this autoloader is not to fix conflicts.
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.
On puli, the conflict is still here:
sullivan@sweetnexy:~/projects/fork/puli/cli(styleci-bridge)$ php-cs-fixer fix -v
Fixer "ordered_use" does not exist, skipping.
Fixer "empty_return" does not exist, skipping.
Loaded config from "/home/sullivan/projects/fork/puli/cli/.php_cs".
Using cache file ".php_cs.cache".
PHP Fatal error: Call to undefined method PhpCsFixer\FixerFileProcessedEvent::setDispatcher() in /home/sullivan/.composer/vendor/symfony/event-dispatcher/EventDispatcher.php on line 42
But this happen only with a composer globally installed php-cs-fixer. The .phar
way works great.
Not sure if this can be easily resolvable.
756bff5
to
a6cc34d
Compare
@Ener-Getick updated. |
LGTM now 👍 |
@soullivaneuh the solution to your problem would be to create your own autoloader: // vendor/.../autoload.php
$loader = new \Composer\Autoload\ClassLoader();
$loader->add('SLLH\StyleCIBridge', __DIR__);
$loader->register(); // .php_cs
require('vendor/.../autoload.php');
//... But I'm wondering if we really need your bridge for this bundle as we use the default configuration of |
You are not using the default, you disabled braces. Also, StyleCI integrate fixer from php-cs-fixer dev-master, so this could be different. This bridge avoid config duplication and ensure working for both PHP-CS-Fixer v1 and v2 at the moment. About the autoloader, this might be right, I have to test. But I have also dependencies to add. I think I'll add it manually. |
@soullivaneuh in fact we disabled |
fine for me. |
I think we should close this. In the current state, it is very likely to create conflicts between libraries and the php-cs-fixer api is good enough to be managed by hand imo. |
I'm closing this as we're back to the standard classes. |
I also made your
.php_cs
config file compatible for both PHP-CS-Fixer v1 and v2.