Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Check/ComposerCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
class ComposerCheck implements SimpleCheckInterface
{

/**
* Return the check's name
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Check/DatabaseCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ class DatabaseCheck implements ListenableCheckInterface
*/
public function __construct()
{
$this->databaseDirectory = $this->getTemporaryPath();
$this->userDatabasePath = sprintf('%s/user-db.sqlite', $this->databaseDirectory);
$this->databaseDirectory = $this->getTemporaryPath();
$this->userDatabasePath = sprintf('%s/user-db.sqlite', $this->databaseDirectory);
$this->solutionDatabasePath = sprintf('%s/solution-db.sqlite', $this->databaseDirectory);
$this->solutionDsn = sprintf('sqlite:%s', $this->solutionDatabasePath);
$this->userDsn = sprintf('sqlite:%s', $this->userDatabasePath);
$this->solutionDsn = sprintf('sqlite:%s', $this->solutionDatabasePath);
$this->userDsn = sprintf('sqlite:%s', $this->userDatabasePath);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Check/FunctionRequirementsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class FunctionRequirementsCheck implements SimpleCheckInterface
{

/**
* @var Parser
*/
Expand Down
1 change: 0 additions & 1 deletion src/Check/PhpLintCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
class PhpLintCheck implements SimpleCheckInterface
{

/**
* Return the check's name
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Command/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ class HelpCommand
* @param OutputInterface $output
* @param Color $color
*/
public function __construct($appName, OutputInterface $output, Color $color)
public function __construct(string $appName, OutputInterface $output, Color $color)
{
$this->output = $output;
$this->color = $color;
$this->appName = $appName;
$this->output = $output;
$this->color = $color;
$this->appName = $appName;
}

/**
* @return void
*/
public function __invoke()
public function __invoke(): void
{
$this->output->writeLine($this->color->__invoke('Usage')->yellow()->bold());
$this->output->writeLine("");
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MenuCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(CliMenu $menu)
/**
* @return void
*/
public function __invoke()
public function __invoke(): void
{
$this->menu->open();
}
Expand Down
16 changes: 8 additions & 8 deletions src/Command/PrintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ class PrintCommand
* @param OutputInterface $output
*/
public function __construct(
$appName,
string $appName,
ExerciseRepository $exerciseRepository,
UserState $userState,
MarkdownRenderer $markdownRenderer,
OutputInterface $output
) {
$this->appName = $appName;
$this->markdownRenderer = $markdownRenderer;
$this->output = $output;
$this->userState = $userState;
$this->exerciseRepository = $exerciseRepository;
$this->appName = $appName;
$this->markdownRenderer = $markdownRenderer;
$this->output = $output;
$this->userState = $userState;
$this->exerciseRepository = $exerciseRepository;
}

/**
* @return int|void
* @return void
*/
public function __invoke()
public function __invoke(): void
{
$currentExercise = $this->userState->getCurrentExercise();
$exercise = $this->exerciseRepository->findByName($currentExercise);
Expand Down
12 changes: 6 additions & 6 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public function __construct(
UserState $userState,
OutputInterface $output
) {
$this->output = $output;
$this->exerciseRepository = $exerciseRepository;
$this->userState = $userState;
$this->exerciseDispatcher = $exerciseDispatcher;
$this->output = $output;
$this->exerciseRepository = $exerciseRepository;
$this->userState = $userState;
$this->exerciseDispatcher = $exerciseDispatcher;
}

/**
* @param Input $input The command line arguments passed to the command.
*
* @return int|void
* @return void
*/
public function __invoke(Input $input)
public function __invoke(Input $input): void
{
$exercise = $this->exerciseRepository->findByName($this->userState->getCurrentExercise());
$this->exerciseDispatcher->run($exercise, $input, $this->output);
Expand Down
16 changes: 8 additions & 8 deletions src/Command/VerifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ public function __construct(
OutputInterface $output,
ResultsRenderer $resultsRenderer
) {
$this->output = $output;
$this->exerciseRepository = $exerciseRepository;
$this->userState = $userState;
$this->userStateSerializer = $userStateSerializer;
$this->resultsRenderer = $resultsRenderer;
$this->exerciseDispatcher = $exerciseDispatcher;
$this->output = $output;
$this->exerciseRepository = $exerciseRepository;
$this->userState = $userState;
$this->userStateSerializer = $userStateSerializer;
$this->resultsRenderer = $resultsRenderer;
$this->exerciseDispatcher = $exerciseDispatcher;
}

/**
* @param Input $input The command line arguments passed to the command.
*
* @return int|void
* @return int
*/
public function __invoke(Input $input)
public function __invoke(Input $input): int
{
$exercise = $this->exerciseRepository->findByName($this->userState->getCurrentExercise());
$results = $this->exerciseDispatcher->verify($exercise, $input);
Expand Down
10 changes: 5 additions & 5 deletions src/CommandArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(string $name, bool $optional = false)
* @param string $name
* @return self
*/
public static function optional($name)
public static function optional(string $name): self
{
return new self($name, true);
}
Expand All @@ -40,31 +40,31 @@ public static function optional($name)
* @param string $name
* @return self
*/
public static function required($name)
public static function required(string $name): self
{
return new self($name);
}

/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* @return bool
*/
public function isRequired()
public function isRequired(): bool
{
return !$this->isOptional();
}

/**
* @return bool
*/
public function isOptional()
public function isOptional(): bool
{
return $this->optional;
}
Expand Down
16 changes: 8 additions & 8 deletions src/CommandDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CommandDefinition
private $name;

/**
* @var CommandArgument[]
* @var array<CommandArgument>
*/
private $args = [];

Expand All @@ -31,10 +31,10 @@ class CommandDefinition
* @param string[]|CommandArgument[] $args A list of arguments. Must be an array of strings or `CommandArgument`'s.
* @param string|callable $commandCallable The name of a callable container entry or an actual PHP callable.
*/
public function __construct($name, array $args, $commandCallable)
public function __construct(string $name, array $args, $commandCallable)
{
$this->name = $name;
$this->commandCallable = $commandCallable;
$this->name = $name;
$this->commandCallable = $commandCallable;

array_walk($args, function ($arg) {
$this->addArgument($arg);
Expand All @@ -45,7 +45,7 @@ public function __construct($name, array $args, $commandCallable)
* @param string|CommandArgument $argument
* @return $this
*/
public function addArgument($argument)
public function addArgument($argument): self
{
if (!is_string($argument) && !$argument instanceof CommandArgument) {
throw InvalidArgumentException::notValidParameter(
Expand Down Expand Up @@ -80,17 +80,17 @@ public function addArgument($argument)
*
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* Get the list of required arguments.
*
* @return CommandArgument[]
* @return array<CommandArgument>
*/
public function getRequiredArgs()
public function getRequiredArgs(): array
{
return $this->args;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CommandRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private function resolveCallable(CommandDefinition $command, Input $input): int
* @param Input $input
* @return ?int
*/
private function callCommand(CommandDefinition $command, callable $callable, Input $input)
private function callCommand(CommandDefinition $command, callable $callable, Input $input): ?int
{
$this->eventDispatcher->dispatch(new Event\Event('route.pre.invoke'));
$this->eventDispatcher->dispatch(new Event\Event(sprintf('route.pre.invoke.%s', $command->getName())));
Expand Down
6 changes: 3 additions & 3 deletions src/Event/ContainerListenerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ContainerListenerHelper
* @param string $service
* @param string $method
*/
public function __construct($service, $method = '__invoke')
public function __construct(string $service, string $method = '__invoke')
{
$this->service = $service;
$this->method = $method;
Expand All @@ -30,15 +30,15 @@ public function __construct($service, $method = '__invoke')
/**
* @return string
*/
public function getService()
public function getService(): string
{
return $this->service;
}

/**
* @return string
*/
public function getMethod()
public function getMethod(): string
{
return $this->method;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Event/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @param string $method
* @return ContainerListenerHelper
*/
function containerListener($service, $method = '__invoke')
function containerListener(string $service, string $method = '__invoke')
{
return new ContainerListenerHelper($service, $method);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CheckNotApplicableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CheckNotApplicableException extends RuntimeException
* @param ExerciseInterface $exercise The exercise Instance.
* @return self
*/
public static function fromCheckAndExercise(CheckInterface $check, ExerciseInterface $exercise)
public static function fromCheckAndExercise(CheckInterface $check, ExerciseInterface $exercise): self
{
return new self(
sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CliRouteNotExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CliRouteNotExistsException extends RuntimeException
/**
* @param string $routeName The name of the command which was typed.
*/
public function __construct($routeName)
public function __construct(string $routeName)
{
parent::__construct(sprintf('Command: "%s" does not exist', $routeName));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CodeExecutionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CodeExecutionException extends RuntimeException
* @param Process $process The `Symfony\Component\Process\Process` instance which failed.
* @return self
*/
public static function fromProcess(Process $process)
public static function fromProcess(Process $process): self
{
return new self(
sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ExerciseNotConfiguredException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ExerciseNotConfiguredException extends RuntimeException
* @param string $interface The FQCN of the interface.
* @return self
*/
public static function missingImplements(ExerciseInterface $exercise, $interface)
public static function missingImplements(ExerciseInterface $exercise, string $interface): self
{
return new self(sprintf('Exercise: "%s" should implement interface: "%s"', $exercise->getName(), $interface));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Exercise/CgiExercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface CgiExercise extends ProvidesSolution
* This method should return an array of PSR-7 requests, which will be forwarded to the student's
* solution.
*
* @return RequestInterface[] An array of PSR-7 requests.
* @return array<RequestInterface> An array of PSR-7 requests.
*/
public function getRequests();
public function getRequests(): array;
}
4 changes: 2 additions & 2 deletions src/Exercise/CliExercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface CliExercise extends ProvidesSolution
* This method should return an array of an array of strings.
* Each set of arguments will be passed to the students solution as command line arguments.
*
* @return string[][] An array of string arguments.
* @return array<array<string>> An array of string arguments.
*/
public function getArgs();
public function getArgs(): array;
}
2 changes: 1 addition & 1 deletion src/Exercise/CustomVerifyingExercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ interface CustomVerifyingExercise
/**
* @return ResultInterface
*/
public function verify();
public function verify(): ResultInterface;
}
2 changes: 1 addition & 1 deletion src/Exercise/SubmissionPatchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ interface SubmissionPatchable
*
* @return Patch
*/
public function getPatch();
public function getPatch(): Patch;
}
4 changes: 2 additions & 2 deletions src/ExerciseCheck/DatabaseExerciseCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface DatabaseExerciseCheck
* @param PDO $db A `PDO` instance pointing to the database which will be accessible to the student's solution.
* @return void
*/
public function seed(PDO $db);
public function seed(PDO $db): void;

/**
* This method allows your exercise to verify the state of database *after* the student's solution has been
Expand All @@ -28,5 +28,5 @@ public function seed(PDO $db);
* @param PDO $db A `PDO` instance pointing to the database which was accessible by the student's solution.
* @return bool The result of the verification.
*/
public function verify(PDO $db);
public function verify(PDO $db): bool;
}
Loading