Skip to content

Commit 1addf17

Browse files
authored
Merge pull request #170 from php-school/cs-fixes
CS Fixes
2 parents d356270 + 50247c6 commit 1addf17

37 files changed

+95
-83
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
1111

1212
### Removed
1313

14+
## [2.3.0]
15+
### Added
16+
- Builds support for PHP 7.4
17+
- Various code cleaning (phpstan, psr12, docblock removal)
18+
19+
### Removed
20+
- Removed support for PHP 7.1
21+
1422
## [2.2.0]
1523
### Added
1624
- Builds for PHP 7.1 & 7.2 (#160)

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,19 @@
4949
]
5050
},
5151
"autoload-dev": {
52-
"psr-4": {
53-
"PhpSchool\\PhpWorkshopTest\\": "test"
52+
"psr-4": {
53+
"PhpSchool\\PhpWorkshopTest\\": "test"
5454
}
5555
},
5656
"scripts" : {
5757
"cs" : [
5858
"phpcs src --standard=PSR12 --encoding=UTF-8",
5959
"phpcs test --standard=PSR12 --encoding=UTF-8"
6060
],
61+
"cs-fix" : [
62+
"phpcbf src --standard=PSR12 --encoding=UTF-8",
63+
"phpcbf test --standard=PSR12 --encoding=UTF-8"
64+
],
6165
"static": "phpstan --ansi analyse --level max src"
6266
}
6367
}

src/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct(string $workshopTitle, string $diConfigFile)
7272
{
7373
Assertion::string($workshopTitle);
7474
Assertion::file($diConfigFile);
75-
75+
7676
$this->workshopTitle = $workshopTitle;
7777
$this->diConfigFile = $diConfigFile;
7878
}
@@ -159,7 +159,7 @@ public function setBgColour(string $colour): void
159159
public function run(): int
160160
{
161161
$container = $this->getContainer();
162-
162+
163163
foreach ($this->exercises as $exercise) {
164164
if (false === $container->has($exercise)) {
165165
throw new \RuntimeException(

src/Check/CodeParseCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac
5858
} catch (Error $e) {
5959
return Failure::fromCheckAndCodeParseFailure($this, $e, $input->getRequiredArgument('program'));
6060
}
61-
61+
6262
return Success::fromCheck($this);
6363
}
6464

src/Check/ComposerCheck.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac
4040
if (!$exercise instanceof ComposerExerciseCheck) {
4141
throw new \InvalidArgumentException();
4242
}
43-
43+
4444
if (!file_exists(sprintf('%s/composer.json', dirname($input->getRequiredArgument('program'))))) {
4545
return new Failure($this->getName(), 'No composer.json file found');
4646
}
@@ -52,12 +52,12 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac
5252
if (!file_exists(sprintf('%s/vendor', dirname($input->getRequiredArgument('program'))))) {
5353
return new Failure($this->getName(), 'No vendor folder found');
5454
}
55-
55+
5656
$lockFile = new LockFileParser(sprintf('%s/composer.lock', dirname($input->getRequiredArgument('program'))));
5757
$missingPackages = array_filter($exercise->getRequiredPackages(), function ($package) use ($lockFile) {
5858
return !$lockFile->hasInstalledPackage($package);
5959
});
60-
60+
6161
if (count($missingPackages) > 0) {
6262
return new Failure(
6363
$this->getName(),

src/CodePatcher.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class CodePatcher
2020
* @var Parser
2121
*/
2222
private $parser;
23-
23+
2424
/**
2525
* @var Standard
2626
*/
2727
private $printer;
28-
28+
2929
/**
3030
* @var Patch|null
3131
*/
@@ -49,7 +49,7 @@ public function __construct(Parser $parser, Standard $printer, Patch $defaultPat
4949
$this->printer = $printer;
5050
$this->defaultPatch = $defaultPatch;
5151
}
52-
52+
5353
/**
5454
* Accepts an exercise and a string containing the students solution to the exercise.
5555
*
@@ -71,7 +71,7 @@ public function patch(ExerciseInterface $exercise, string $code): string
7171
if ($exercise instanceof SubmissionPatchable) {
7272
$code = $this->applyPatch($exercise->getPatch(), $code);
7373
}
74-
74+
7575
return $code;
7676
}
7777

src/Command/CreditsCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CreditsCommand
1414
* @var OutputInterface
1515
*/
1616
private $output;
17-
17+
1818
/**
1919
* @var Color
2020
*/
@@ -61,7 +61,7 @@ private function writeContributors(array $contributors): void
6161
$this->output->writeLine(sprintf("%s %s", str_pad($name, (int) $nameColumnSize), $gitHubUser));
6262
}
6363
}
64-
64+
6565
/**
6666
*
6767
* @return void
@@ -71,7 +71,7 @@ public function __invoke(): void
7171
if (empty($this->coreContributors)) {
7272
return;
7373
}
74-
74+
7575
$this->output->writeLine(
7676
$this->color->__invoke("PHP School is bought to you by...")->yellow()->__toString()
7777
);
@@ -84,7 +84,7 @@ public function __invoke(): void
8484

8585
$this->output->emptyLine();
8686
$this->output->emptyLine();
87-
87+
8888
$this->output->writeLine(
8989
$this->color->__invoke("This workshop is brought to you by...")->yellow()->__toString()
9090
);

src/Command/HelpCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class HelpCommand
1515
* @var string
1616
*/
1717
private $appName;
18-
18+
1919
/**
2020
* @var OutputInterface
2121
*/
@@ -37,7 +37,7 @@ public function __construct($appName, OutputInterface $output, Color $color)
3737
$this->color = $color;
3838
$this->appName = $appName;
3939
}
40-
40+
4141
/**
4242
* @return void
4343
*/

src/Command/VerifyCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class VerifyCommand
3535
* @var UserStateSerializer
3636
*/
3737
private $userStateSerializer;
38-
38+
3939
/**
4040
* @var ResultsRenderer
4141
*/
@@ -84,7 +84,7 @@ public function __invoke(Input $input)
8484
$this->userState->addCompletedExercise($exercise->getName());
8585
$this->userStateSerializer->serialize($this->userState);
8686
}
87-
87+
8888
$this->resultsRenderer->render($results, $exercise, $this->userState, $this->output);
8989
return $results->isSuccessful() ? 0 : 1;
9090
}

src/ComposerUtil/LockFileParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(string $lockFilePath)
2323
if (!file_exists($lockFilePath)) {
2424
throw new InvalidArgumentException(sprintf('Lock File: "%s" does not exist', $lockFilePath));
2525
}
26-
26+
2727
$this->contents = json_decode((string) file_get_contents($lockFilePath), true);
2828

2929
if (!isset($this->contents['packages'])) {
@@ -66,7 +66,7 @@ public function hasInstalledPackage($packageName): bool
6666
return true;
6767
}
6868
}
69-
69+
7070
return false;
7171
}
7272
}

0 commit comments

Comments
 (0)