Skip to content

Commit

Permalink
Merge pull request #2 from oliver-la/patch-1
Browse files Browse the repository at this point in the history
PHP 8.x compatibility: Fix deprecation notice
  • Loading branch information
nelson6e65 authored Jun 6, 2024
2 parents 7cf9560 + ff662f4 commit 15c5b15
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function phpcbf(Event $event): void
$ignoredPaths = [];

if ($count > 0) {
$event->getIO()->write("Fixing PHP Coding Standard of ${count} paths.");
$event->getIO()->write("Fixing PHP Coding Standard of {$count} paths.");

foreach ($files as $i => $file) {
$realPath = realpath($file);
Expand All @@ -87,19 +87,19 @@ public static function phpcbf(Event $event): void

$type = strlen($relativePath) < 4 || stripos($relativePath, '.php', -4) === false ? 'directory' : 'file';

$event->getIO()->write("Improving <info>${relativePath}</info> ${type}...");
$event->getIO()->write("Improving <info>{$relativePath}</info> {$type}...");

$output = [];
$return = 0;

// NOTE: workarround: need to run 2 times due to a bug that exits 1 instead of 0 when a file gets fixed
// https://github.com/squizlabs/PHP_CodeSniffer/issues/1818#issuecomment-735620637
exec("${cmd} \"${realPath}\" || ${cmd} \"${realPath}\" -q", $output, $return);
exec("{$cmd} \"{$realPath}\" || {$cmd} \"{$realPath}\" -q", $output, $return);

$event->getIO()->write($output, true, IOInterface::VERBOSE);

if ($return !== 0) {
$event->getIO()->error("Error! Unable to autofix the ${relativePath} file!");
$event->getIO()->error("Error! Unable to autofix the {$relativePath} file!");
$event->getIO()->write(
'<comment>Run <options=bold>`phpcs`</> manually to check the conflicting files</comment>'
);
Expand All @@ -113,7 +113,7 @@ public static function phpcbf(Event $event): void
$end_time = microtime(true);
$execution_time = round($end_time - $start_time, 2);

$event->getIO()->write("Done in ${execution_time}s");
$event->getIO()->write("Done in {$execution_time}s");

if (count($ignoredPaths)) {
$ignoredPaths = array_map(function ($item) {
Expand Down

0 comments on commit 15c5b15

Please sign in to comment.