-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Uncaught RuntimeException when phpcbf fails to fix files #1615
Comments
Are you able to provide the file so I can try and replicate the error. Or a smaller section of the file that reproduces the error? |
@gsherwood Weird, I tried doing it couple of more times and the issue just disappeared. No idea why :/ |
If it comes back and you can provide a bit of code to replicate, please post it and I'll take a look. |
@gsherwood Sure :) |
I've just run into what looks to be the same error:
I've been able to consistently reproduce this on a file which runs into a fixer conflict using the following ruleset: <?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>Apply WordPress Coding Standards to all Core files</description>
<rule ref="WordPress-Core" />
<rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
<arg name="extensions" value="php" />
<!-- Show sniff codes in all reports -->
<arg value="ps" />
</ruleset> in combination with the following command: phpcbf -vv ./src/wp-admin/includes/ms.php --standard=phpcs5.xml The file I was trying to fix can be found here: The fixer conflict is a different issue which I will be looking into, the fatal error being thrown is why I'm reporting it. |
As a side-note: it seems the new line is missing before the "* fixed 1 violations, starting loop 47 *" phrase. |
Having the same issue as @jrfnl has, with Command: Error and Stack trace: File to fix: <?php
namespace Core\ServiceProviders;
use Blade;
use Illuminate\Support\ServiceProvider;
class BladeServiceProvider extends ServiceProvider
{
public function boot()
{
Blade::directive('pushonce', function ($expression) {
$domain = explode(':', trim(substr($expression, 1, -1)));
$push_name = $domain[0];
$push_sub = $domain[1];
$isDisplayed = '__pushonce_'.$push_name.'_'.$push_sub;
return "<?php if(!isset(\$__env->{$isDisplayed})): \$__env->{$isDisplayed} = true; \$__env->startPush('{$push_name}'); ?>";
});
Blade::directive('endpushonce', function ($expression) {
return '<?php $__env->stopPush(); endif; ?>';
});
}
} php versions: 7.0.18, and 7.1.4 |
I've committed a change that I think fixes this. The ob_end_clean() line was already muted, so that code may get run with an open or closed buffer. I've changed to code to actually check the buffer state now, which has fixed the test case @jrfnl submitted. If anyone finds additional test cases, please post them (I'll need your ruleset as well) and I'll take a look. Otherwise, I think this is now fixed so I'll close it off. |
@gsherwood Thanks for that. I will let you know if I run into this again, but the fix looks good to me. 🤞 |
@gsherwood Now it's working, Thanks!)) |
|
Im getting what might be a similar problem. I run on a specific file and no changes take effect with output:
I ran with -vvv and chucked it in a file if that helps at all |
I tried to run
phpcs
on my file and it gave me this output:When I increased the verbosity, It gave me this output:
The text was updated successfully, but these errors were encountered: