Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Jun 8, 2024
1 parent d237f79 commit d550c38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Features/Psr4/CheckPsr4Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function fixedNamespace($file, $wrong, $correct, $class, $lineNumb
$key = 'badNamespace';
$printer = ErrorPrinter::singleton();

$errorData = ' Namespace of class "'.$class.'" fixed to: '.$printer->color("$correct");
$errorData = ' Namespace of class "'.$class.'" fixed to: '.$printer->color($correct);

$printer->addPendingError($path, $lineNumber, $key, $errorData, '');
}
Expand Down
3 changes: 3 additions & 0 deletions src/Features/Psr4/NamespaceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public static function fix(PhpFileDescriptor $file, $incorrectNamespace, $correc
while ($tokens[$i] !== ';') {
$i++;
}
while (! isset($tokens[$i][2])) {
$i++;
}
$file->insertNewLine(PHP_EOL.$newline, $tokens[$i][2] + 1);
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/Features/Psr4/Psr4Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ private static function handleError($error)
if ($error['type'] === 'namespace') {
self::askAndFixNamespace($error);
} elseif ($error['type'] === 'filename') {
CheckPsr4Printer::wrongFileName(
$error['relativePath'],
$error['class'],
$error['fileName']
);
self::wrongFileName($error);
}
}

Expand Down Expand Up @@ -67,4 +63,13 @@ private static function askAndFixNamespace($error)
$error['correctNamespace']
);
}

private static function wrongFileName($error)
{
CheckPsr4Printer::wrongFileName(
$error['relativePath'],
$error['class'],
$error['fileName']
);
}
}

0 comments on commit d550c38

Please sign in to comment.