-
Notifications
You must be signed in to change notification settings - Fork 19
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
Styleci bridge #21
base: master
Are you sure you want to change the base?
Styleci bridge #21
Conversation
Thanks for this! :) |
// PHP-CS-Fixer 2.x | ||
if (method_exists($config, 'setRules')) { | ||
$config | ||
->setRiskyAllowed(true) |
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.
What does this mean?
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.
Risky fixers are not allowed by default on 2.x.
But it's possible you don't need it with your configuration. Will try and remove it if it's true.
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.
Any update on this?
When I try this, I get a:
with php-cs-fixer 1.10.1. Is this familiar? |
Well, never get this error. Could you please give me the complete entered command and |
I reproduced it but I didn't find where is the issue yet. You can avoid this error by setting |
More strange thing, the error seems to come from your code:
|
Ah, I just realized what the problem is. You are loading the project's autoloader in .php_cs, which may conflict with the libraries bundled with php-cs-fixer (and that seems to be the case right now). |
Yes, this is needed to get the bridge working.
Yeah, but what I don't understand is the location of the error. Regarding php trace, it seems to provide from your code. That makes no sense to me. Any idea? |
Well, I was wrong this is coming from Symfony vendor, not your code. But it's not an error from my lib call, this is hard to debug. |
a0327e5
to
a9e9d32
Compare
@webmozart Could you tell me if you still get this error with the following modification? If it's solved, I'll try to make a custom loader on my project to prevent this kind of things. |
a9e9d32
to
9d40846
Compare
@webmozart Should be ok this time. :-) I released a new patch version of the bridge with a custom loader to avoid this kind of conflicts. 👍 |
Nice, thanks :) How do you run PHP-CS-Fixer? The tool hangs for me.. there must be an infinite loop somewhere. |
Ah, no! Apparently it just takes a lot of network bandwidth and I'm on a slow connection right now. Why is that so? |
The bridge does not download anything... Oo What is your command? Just run |
ping @webmozart |
Hm, seems to work now. |
I ensure you that no internet connection is done from the bridge. If you have some, this is from another library / tools. |
I just reviewed your autoload.php, but I don't get how this is different now. What's the point of this custom class loader? You are still forwarding everything to the project's autoloader, no? |
Yes, but I only load needed classes on runtime. So, no conflict like you got. |
Can you explain this a bit more? I thought loading the classes at runtime was the purpose of Composer's autoloader? |
I'm not an expert but I don't think so. Seems all classes are registered. That why the |
BTW, this autoload is used only for php-cs-fixer. No side effect with your project. |
Registered, yes, but not loaded. Classes are only loaded when they are used (e.g. |
Well, you're right, I asked Seldaek for more info. I think this is related to // autoload_real.php @generated by Composer
class ComposerAutoloaderInit065a5b652db51bcdb5d3d6134bf669ad
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit065a5b652db51bcdb5d3d6134bf669ad', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit065a5b652db51bcdb5d3d6134bf669ad', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register(true);
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequire065a5b652db51bcdb5d3d6134bf669ad($file);
}
return $loader;
}
}
function composerRequire065a5b652db51bcdb5d3d6134bf669ad($file)
{
require $file;
} BTW, removing the |
@webmozart I asked for that. Please see composer/composer#1493 (comment). |
@soullivaneuh any progress? |
@theofidry for me the PR is ready. Waiting @webmozart confirmation since the question asked to Seldaek. |
9d40846
to
bb646cf
Compare
bb646cf
to
effd752
Compare
Hi @webmozart, going back to this old and tricky PR. :-) I removed the custom autoload requirement. Your issue mentioned in #21 (comment) looks to happen only when running php-cs-fixer from a global composer installation. Tries with the I would just recommend to use the I already have strange errors like this with composer globally installed tools. Recently with PHPUnit, telling me test passes when it should fail because I didn't require Ready to merge for my side. 👍 |
As discussed on Gitter.
cc @theofidry