Skip to content
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

Closed

Conversation

soullivaneuh
Copy link
Contributor

@soullivaneuh soullivaneuh commented Jun 27, 2016

I also made your .php_cs config file compatible for both PHP-CS-Fixer v1 and v2.

@xabbuh
Copy link
Member

xabbuh commented Jun 27, 2016

I don't think that we need to support both versions as the CS fixer is only required as a dev dependency.

@soullivaneuh
Copy link
Contributor Author

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';
Copy link
Member

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 ?

Copy link
Contributor Author

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

Copy link
Member

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 ;)

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@soullivaneuh soullivaneuh force-pushed the php-cs-fixer-bridge-2.0 branch from 756bff5 to a6cc34d Compare June 29, 2016 08:26
@soullivaneuh
Copy link
Contributor Author

@Ener-Getick updated.

@GuilhemN
Copy link
Member

LGTM now 👍

@GuilhemN
Copy link
Member

GuilhemN commented Jun 29, 2016

@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 php-cs-fixer anyway...

@soullivaneuh
Copy link
Contributor Author

as we use the default configuration of php-cs-fixer anyway...

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.

@GuilhemN
Copy link
Member

@soullivaneuh in fact we disabled braces to have the same behaviour than php-cs-fixer. WDYT @xabbuh @lsmith77 ?

@lsmith77
Copy link
Member

lsmith77 commented Jul 5, 2016

fine for me.

@GuilhemN
Copy link
Member

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.

@GuilhemN
Copy link
Member

GuilhemN commented Sep 7, 2016

I'm closing this as we're back to the standard classes.

@GuilhemN GuilhemN closed this Sep 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants