Skip to content

Commit

Permalink
refactor: update code for php 8
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Feb 20, 2021
1 parent 604bbe0 commit 590941c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/Process/Process.php
Expand Up @@ -25,6 +25,7 @@
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use ReflectionNamedType;
use Symfony\Component\Process\Process as SymfonyProcess;

use function array_map;
Expand Down Expand Up @@ -63,9 +64,12 @@ protected function useCorrectCommand(array $command)

/** @var ReflectionMethod $reflectedConstructor */
$reflectedConstructor = $reflectedProcess->getConstructor();
$reflectedConstructorType = $reflectedConstructor->getParameters()[0]->getType();

if ($reflectedConstructor->getParameters()[0]->isArray()) {
return $command;
if ($reflectedConstructorType instanceof ReflectionNamedType) {
if ($reflectedConstructorType->getName() === 'array') {
return $command;
}
}

$commandLine = array_shift($command) . ' ';
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/PhpunitRunCommand.php
Expand Up @@ -151,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$output->writeln('');

$exitCode = (int) $process->wait(
$exitCode = $process->wait(
function (string $type, string $buffer) use ($output): void {
$output->write($buffer);
},
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/PhpunitTestCommand.php
Expand Up @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new InvalidArgumentException('The assertion provided is not valid');
}

$functionName = (string) ($matches[1] ?? '');
$functionName = $matches[1] ?? '';

if (!method_exists($phpunitTestCase, $functionName)) {
throw new InvalidArgumentException("{$functionName} is not a PHPUnit assertion method");
Expand Down
2 changes: 1 addition & 1 deletion src/Repl.php
Expand Up @@ -97,7 +97,7 @@ private function getStartupMessage(): string
------------------------------------------------------------------------
EOD;

$packageName = (string) $this->composer->getPackage()->getPrettyName();
$packageName = $this->composer->getPackage()->getPrettyName();

return sprintf($startupMessage, $packageName);
}
Expand Down

0 comments on commit 590941c

Please sign in to comment.