Migrates to Pint

This commit is contained in:
Nuno Maduro
2022-09-16 10:45:53 +01:00
parent 579b975318
commit e9564febaf
94 changed files with 413 additions and 471 deletions

View File

@ -17,8 +17,7 @@ final class HandleArguments
*
* Transform the input arguments by passing it to the relevant plugins.
*
* @param array<int, string> $argv
*
* @param array<int, string> $argv
* @return array<int, string>
*/
public function __invoke(array $argv): array

View File

@ -12,7 +12,7 @@ trait HandleArguments
/**
* Checks if the given argument exists on the arguments.
*
* @param array<int, string> $arguments
* @param array<int, string> $arguments
*/
public function hasArgument(string $argument, array $arguments): bool
{
@ -22,8 +22,7 @@ trait HandleArguments
/**
* Adds the given argument and value to the list of arguments.
*
* @param array<int, string> $arguments
*
* @param array<int, string> $arguments
* @return array<int, string>
*/
public function pushArgument(string $argument, array $arguments): array
@ -36,8 +35,7 @@ trait HandleArguments
/**
* Pops the given argument from the arguments.
*
* @param array<int, string> $arguments
*
* @param array<int, string> $arguments
* @return array<int, string>
*/
public function popArgument(string $argument, array $arguments): array

View File

@ -66,15 +66,15 @@ final class Coverage implements AddsOutput, HandlesArguments
}
$originals = array_flip($originals);
$inputs = [];
$inputs = [];
$inputs[] = new InputOption(self::COVERAGE_OPTION, null, InputOption::VALUE_NONE);
$inputs[] = new InputOption(self::MIN_OPTION, null, InputOption::VALUE_REQUIRED);
$input = new ArgvInput($arguments, new InputDefinition($inputs));
if ((bool) $input->getOption(self::COVERAGE_OPTION)) {
$this->coverage = true;
$originals[] = '--coverage-php';
$originals[] = \Pest\Support\Coverage::getPath();
$originals[] = '--coverage-php';
$originals[] = \Pest\Support\Coverage::getPath();
}
if ($input->getOption(self::MIN_OPTION) !== null) {
@ -93,7 +93,7 @@ final class Coverage implements AddsOutput, HandlesArguments
public function addOutput(int $exitCode): int
{
if ($exitCode === 0 && $this->coverage) {
if (!\Pest\Support\Coverage::isAvailable()) {
if (! \Pest\Support\Coverage::isAvailable()) {
$this->output->writeln(
"\n <fg=white;bg=red;options=bold> ERROR </> No code coverage driver is available.</>",
);

View File

@ -23,8 +23,8 @@ final class Init implements HandlesArguments
* The files that will be created.
*/
private const STUBS = [
'phpunit.xml' => 'phpunit.xml',
'Pest.php' => 'tests/Pest.php',
'phpunit.xml' => 'phpunit.xml',
'Pest.php' => 'tests/Pest.php',
'ExampleTest.php' => 'tests/ExampleTest.php',
];
@ -43,7 +43,7 @@ final class Init implements HandlesArguments
*/
public function handleArguments(array $arguments): array
{
if (!array_key_exists(1, $arguments) || $arguments[1] !== self::INIT_OPTION) {
if (! array_key_exists(1, $arguments) || $arguments[1] !== self::INIT_OPTION) {
return $arguments;
}
@ -58,8 +58,8 @@ final class Init implements HandlesArguments
{
$testsBaseDir = "{$this->testSuite->rootPath}/tests";
if (!is_dir($testsBaseDir)) {
if (!mkdir($testsBaseDir) && !is_dir($testsBaseDir)) {
if (! is_dir($testsBaseDir)) {
if (! mkdir($testsBaseDir) && ! is_dir($testsBaseDir)) {
$this->output->writeln(sprintf(
"\n <fg=white;bg=red;options=bold> ERROR </> Directory `%s` was not created.</>",
$testsBaseDir
@ -74,8 +74,8 @@ final class Init implements HandlesArguments
}
foreach (self::STUBS as $from => $to) {
$fromPath = __DIR__ . "/../../stubs/init/{$from}";
$toPath = "{$this->testSuite->rootPath}/{$to}";
$fromPath = __DIR__."/../../stubs/init/{$from}";
$toPath = "{$this->testSuite->rootPath}/{$to}";
if (file_exists($toPath)) {
$this->output->writeln(sprintf(
@ -86,16 +86,16 @@ final class Init implements HandlesArguments
continue;
}
if ($from === 'phpunit.xml' && file_exists($toPath . '.dist')) {
if ($from === 'phpunit.xml' && file_exists($toPath.'.dist')) {
$this->output->writeln(sprintf(
' <fg=black;bg=yellow;options=bold> INFO </> File `%s` already exists, skipped.</>',
$to . '.dist'
$to.'.dist'
));
continue;
}
if (!copy($fromPath, $toPath)) {
if (! copy($fromPath, $toPath)) {
$this->output->writeln(sprintf(
'<fg=black;bg=red>[WARNING] Failed to copy stub `%s` to `%s`</>',
$from,

View File

@ -18,7 +18,7 @@ final class Printer implements HandlesArguments
*/
public function handleArguments(array $arguments): array
{
if (!array_key_exists('COLLISION_PRINTER', $_SERVER)) {
if (! array_key_exists('COLLISION_PRINTER', $_SERVER)) {
return $arguments;
}

View File

@ -5,9 +5,7 @@ declare(strict_types=1);
namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments;
use function Pest\version;
use Symfony\Component\Console\Output\OutputInterface;
/**