Skip to content

PSR-12 #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2020
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
28 changes: 0 additions & 28 deletions appveyor.yml

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
},
"scripts" : {
"cs" : [
"phpcs src --standard=PSR2 --encoding=UTF-8",
"phpcs test --standard=PSR2 --encoding=UTF-8"
"phpcs src --standard=PSR12 --encoding=UTF-8",
"phpcs test --standard=PSR12 --encoding=UTF-8"
]
}
}
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function run()
*/
private function getContainer()
{
$containerBuilder = new ContainerBuilder;
$containerBuilder = new ContainerBuilder();
$containerBuilder->addDefinitions(
array_merge_recursive(
require $this->frameworkConfigLocation,
Expand Down
4 changes: 2 additions & 2 deletions src/Check/CheckInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ interface CheckInterface
/**
* Return the check's name
*/
public function getName() : string;
public function getName(): string;

/**
* This returns the interface the exercise should implement
* when requiring this check. It should be the FQCN of the interface.
*/
public function getExerciseInterface() : string;
public function getExerciseInterface(): string;
}
8 changes: 4 additions & 4 deletions src/Check/CheckRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(array $checks = [])
/**
* Add a new check to the repository.
*/
public function registerCheck(CheckInterface $check) : void
public function registerCheck(CheckInterface $check): void
{
$this->checks[get_class($check)] = $check;
}
Expand All @@ -38,7 +38,7 @@ public function registerCheck(CheckInterface $check) : void
*
* @return array
*/
public function getAll() : array
public function getAll(): array
{
return array_values($this->checks);
}
Expand All @@ -50,7 +50,7 @@ public function getAll() : array
* @return CheckInterface The instance.
* @throws InvalidArgumentException If an instance of the check does not exist.
*/
public function getByClass(string $class) : CheckInterface
public function getByClass(string $class): CheckInterface
{
if (!isset($this->checks[$class])) {
throw new InvalidArgumentException(sprintf('Check: "%s" does not exist', $class));
Expand All @@ -62,7 +62,7 @@ public function getByClass(string $class) : CheckInterface
/**
* Query whether a check instance exists in this repository via its class name.
*/
public function has(string $class) : bool
public function has(string $class): bool
{
try {
$this->getByClass($class);
Expand Down
10 changes: 5 additions & 5 deletions src/Check/CodeParseCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(Parser $parser)
/**
* Return the check's name
*/
public function getName() : string
public function getName(): string
{
return 'Code Parse Check';
}
Expand All @@ -49,7 +49,7 @@ public function getName() : string
* @param Input $input The command line arguments passed to the command.
* @return ResultInterface The result of the check.
*/
public function check(ExerciseInterface $exercise, Input $input) : ResultInterface
public function check(ExerciseInterface $exercise, Input $input): ResultInterface
{

$code = file_get_contents($input->getArgument('program'));
Expand All @@ -66,15 +66,15 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa
/**
* This check can run on any exercise type.
*/
public function canRun(ExerciseType $exerciseType) : bool
public function canRun(ExerciseType $exerciseType): bool
{
return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true);
}

/**
* @return string
*/
public function getExerciseInterface() : string
public function getExerciseInterface(): string
{
return ExerciseInterface::class;
}
Expand All @@ -83,7 +83,7 @@ public function getExerciseInterface() : string
* This check should be run before executing the student's solution, as, if it cannot be parsed
* it probably cannot be executed.
*/
public function getPosition() : string
public function getPosition(): string
{
return SimpleCheckInterface::CHECK_BEFORE;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Check/ComposerCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ComposerCheck implements SimpleCheckInterface
/**
* Return the check's name
*/
public function getName() : string
public function getName(): string
{
return 'Composer Dependency Check';
}
Expand All @@ -35,10 +35,10 @@ public function getName() : string
* @param Input $input The command line arguments passed to the command.
* @return ResultInterface The result of the check.
*/
public function check(ExerciseInterface $exercise, Input $input) : ResultInterface
public function check(ExerciseInterface $exercise, Input $input): ResultInterface
{
if (!$exercise instanceof ComposerExerciseCheck) {
throw new \InvalidArgumentException;
throw new \InvalidArgumentException();
}

if (!file_exists(sprintf('%s/composer.json', dirname($input->getArgument('program'))))) {
Expand Down Expand Up @@ -74,20 +74,20 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa
/**
* This check can run on any exercise type.
*/
public function canRun(ExerciseType $exerciseType) : bool
public function canRun(ExerciseType $exerciseType): bool
{
return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true);
}

public function getExerciseInterface() : string
public function getExerciseInterface(): string
{
return ComposerExerciseCheck::class;
}

/**
* This check can run before because if it fails, there is no point executing the solution.
*/
public function getPosition() : string
public function getPosition(): string
{
return SimpleCheckInterface::CHECK_BEFORE;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Check/DatabaseCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public function __construct()
/**
* Return the check's name
*/
public function getName() : string
public function getName(): string
{
return 'Database Verification Check';
}

public function getExerciseInterface() : string
public function getExerciseInterface(): string
{
return DatabaseExerciseCheck::class;
}
Expand All @@ -75,7 +75,7 @@ public function getExerciseInterface() : string
* Here we attach to various events to seed, verify and inject the DSN's
* to the student & reference solution programs's CLI arguments.
*/
public function attach(EventDispatcher $eventDispatcher) : void
public function attach(EventDispatcher $eventDispatcher): void
{
if (file_exists($this->databaseDirectory)) {
throw new \RuntimeException(
Expand Down
10 changes: 5 additions & 5 deletions src/Check/FileExistsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FileExistsCheck implements SimpleCheckInterface
/**
* Return the check's name.
*/
public function getName() : string
public function getName(): string
{
return 'File Exists Check';
}
Expand All @@ -29,7 +29,7 @@ public function getName() : string
* @param Input $input The command line arguments passed to the command.
* @return ResultInterface The result of the check.
*/
public function check(ExerciseInterface $exercise, Input $input) : ResultInterface
public function check(ExerciseInterface $exercise, Input $input): ResultInterface
{
if (file_exists($input->getArgument('program'))) {
return Success::fromCheck($this);
Expand All @@ -41,20 +41,20 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa
/**
* This check can run on any exercise type.
*/
public function canRun(ExerciseType $exerciseType) : bool
public function canRun(ExerciseType $exerciseType): bool
{
return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true);
}

public function getExerciseInterface() : string
public function getExerciseInterface(): string
{
return ExerciseInterface::class;
}

/**
* This check must run before executing the solution becuase it may not exist.
*/
public function getPosition() : string
public function getPosition(): string
{
return SimpleCheckInterface::CHECK_BEFORE;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Check/FunctionRequirementsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Parser $parser)
/**
* Return the check's name.
*/
public function getName() : string
public function getName(): string
{
return 'Function Requirements Check';
}
Expand All @@ -53,10 +53,10 @@ public function getName() : string
* @param Input $input The command line arguments passed to the command.
* @return ResultInterface The result of the check.
*/
public function check(ExerciseInterface $exercise, Input $input) : ResultInterface
public function check(ExerciseInterface $exercise, Input $input): ResultInterface
{
if (!$exercise instanceof FunctionRequirementsExerciseCheck) {
throw new \InvalidArgumentException;
throw new \InvalidArgumentException();
}

$requiredFunctions = $exercise->getRequiredFunctions();
Expand All @@ -71,7 +71,7 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa
}

$visitor = new FunctionVisitor($requiredFunctions, $bannedFunctions);
$traverser = new NodeTraverser;
$traverser = new NodeTraverser();
$traverser->addVisitor($visitor);

$traverser->traverse($ast);
Expand All @@ -98,12 +98,12 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa
/**
* This check can run on any exercise type.
*/
public function canRun(ExerciseType $exerciseType) : bool
public function canRun(ExerciseType $exerciseType): bool
{
return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true);
}

public function getExerciseInterface() : string
public function getExerciseInterface(): string
{
return FunctionRequirementsExerciseCheck::class;
}
Expand All @@ -113,7 +113,7 @@ public function getExerciseInterface() : string
* output, but do it in a way that was not correct for the task. This way the student can see the program works
* but missed some requirements.
*/
public function getPosition() : string
public function getPosition(): string
{
return SimpleCheckInterface::CHECK_AFTER;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Check/ListenableCheckInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ interface ListenableCheckInterface extends CheckInterface
* Attach to events throughout the running/verifying process. Inject verifiers
* and listeners.
*/
public function attach(EventDispatcher $eventDispatcher) : void;
public function attach(EventDispatcher $eventDispatcher): void;
}
10 changes: 5 additions & 5 deletions src/Check/PhpLintCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PhpLintCheck implements SimpleCheckInterface
/**
* Return the check's name
*/
public function getName() : string
public function getName(): string
{
return 'PHP Code Check';
}
Expand All @@ -32,7 +32,7 @@ public function getName() : string
* @param Input $input The command line arguments passed to the command.
* @return ResultInterface The result of the check.
*/
public function check(ExerciseInterface $exercise, Input $input) : ResultInterface
public function check(ExerciseInterface $exercise, Input $input): ResultInterface
{
$process = new Process([PHP_BINARY, '-l', $input->getArgument('program')]);
$process->run();
Expand All @@ -47,12 +47,12 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa
/**
* This check can run on any exercise type.
*/
public function canRun(ExerciseType $exerciseType) : bool
public function canRun(ExerciseType $exerciseType): bool
{
return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true);
}

public function getExerciseInterface() : string
public function getExerciseInterface(): string
{
return ExerciseInterface::class;
}
Expand All @@ -61,7 +61,7 @@ public function getExerciseInterface() : string
* This check should be run before executing the student's solution, as, if it cannot be linted
* it probably cannot be executed.
*/
public function getPosition() : string
public function getPosition(): string
{
return SimpleCheckInterface::CHECK_BEFORE;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Check/SimpleCheckInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface SimpleCheckInterface extends CheckInterface
/**
* Can this check run this exercise?
*/
public function canRun(ExerciseType $exerciseType) : bool;
public function canRun(ExerciseType $exerciseType): bool;

/**
* The check is ran against an exercise and a filename which
Expand All @@ -45,12 +45,12 @@ public function canRun(ExerciseType $exerciseType) : bool;
* @param Input $input The command line arguments passed to the command.
* @return ResultInterface The result of the check.
*/
public function check(ExerciseInterface $exercise, Input $input) : ResultInterface;
public function check(ExerciseInterface $exercise, Input $input): ResultInterface;

/**
* Either `static::CHECK_BEFORE` | `static::CHECK_AFTER`.
*
* @return string
*/
public function getPosition() : string;
public function getPosition(): string;
}
4 changes: 2 additions & 2 deletions src/CodeInsertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class CodeInsertion
* Denotes that the block of code this insertion
* represents, should be inserted at the top of the solution.
*/
const TYPE_BEFORE = 'before';
public const TYPE_BEFORE = 'before';

/**
* Denotes that the block of code this insertion
* represents, should be inserted at the bottom of the solution.
*/
const TYPE_AFTER = 'after';
public const TYPE_AFTER = 'after';

/**
* @var array
Expand Down
Loading