Skip to content

Commit 90a42fc

Browse files
committed
phpstan level 3
1 parent fdc8c9c commit 90a42fc

21 files changed

+55
-39
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@
5656
"phpcs src --standard=PSR12 --encoding=UTF-8",
5757
"phpcs test --standard=PSR12 --encoding=UTF-8"
5858
],
59-
"static": "phpstan --ansi analyse --level 1 src"
59+
"static": "phpstan --ansi analyse --level 3 src"
6060
}
6161
}

src/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class Application
2727
private $checks = [];
2828

2929
/**
30-
* @var ExerciseInterface[]
30+
* @var class-string[]
3131
*/
3232
private $exercises = [];
3333

@@ -92,7 +92,7 @@ public function addCheck($check)
9292
* Register an exercise with the application. Only exercises registered here will
9393
* be displayed in the exercise menu.
9494
*
95-
* @param string $exercise The FQCN of the check
95+
* @param class-string $exercise The FQCN of the check
9696
*/
9797
public function addExercise($exercise)
9898
{

src/Check/DatabaseCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class DatabaseCheck implements ListenableCheckInterface
3737
private $solutionDatabasePath;
3838

3939
/**
40-
* @var
40+
* @var string
4141
*/
4242
private $userDsn;
4343

src/ComposerUtil/LockFileParser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class LockFileParser
1111
{
1212
/**
13-
* @var string
13+
* @var array
1414
*/
1515
private $contents;
1616

@@ -25,6 +25,10 @@ public function __construct($lockFilePath)
2525
}
2626

2727
$this->contents = json_decode(file_get_contents($lockFilePath), true);
28+
29+
if (!isset($this->contents['packages'])) {
30+
throw new InvalidArgumentException(sprintf('Lock File: "%s" does not contain packages key', $lockFilePath));
31+
}
2832
}
2933

3034
/**

src/Event/ContainerListenerHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ContainerListenerHelper
1818
private $method;
1919

2020
/**
21-
* @param $service
21+
* @param string $service
2222
* @param string $method
2323
*/
2424
public function __construct($service, $method = '__invoke')

src/Event/EventInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PhpSchool\PhpWorkshop\Event;
44

5+
use PhpSchool\PhpWorkshop\Exception\InvalidArgumentException;
6+
57
/**
68
* An event representation.
79
*/

src/Exception/InvalidArgumentException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function missingImplements($object, $requiredInterface)
6262
}
6363

6464
/**
65-
* @param $value
65+
* @param mixed $value
6666
* @return string
6767
*/
6868
private static function stringify($value)

src/ExerciseDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function run(ExerciseInterface $exercise, Input $input, OutputInterface $
193193
}
194194

195195
/**
196-
* @param CheckInterface[] $checks
196+
* @param SimpleCheckInterface[] $checks
197197
* @param ExerciseInterface $exercise
198198
* @throws CheckNotApplicableException
199199
* @throws ExerciseNotConfiguredException

src/ExerciseRunner/CgiRunner.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public function getRequiredChecks()
124124
private function checkRequest(RequestInterface $request, $fileName)
125125
{
126126
try {
127+
/** @var CgiExecuteEvent $event */
127128
$event = $this->eventDispatcher->dispatch(
128129
new CgiExecuteEvent('cgi.verify.reference-execute.pre', $request)
129130
);
@@ -138,6 +139,7 @@ private function checkRequest(RequestInterface $request, $fileName)
138139
}
139140

140141
try {
142+
/** @var CgiExecuteEvent $event */
141143
$event = $this->eventDispatcher->dispatch(new CgiExecuteEvent('cgi.verify.student-execute.pre', $request));
142144
$userResponse = $this->executePhpFile($fileName, $event->getRequest(), 'student');
143145
} catch (CodeExecutionException $e) {
@@ -284,6 +286,7 @@ public function run(Input $input, OutputInterface $output)
284286
$this->eventDispatcher->dispatch(new ExerciseRunnerEvent('cgi.run.start', $this->exercise, $input));
285287
$success = true;
286288
foreach ($this->exercise->getRequests() as $i => $request) {
289+
/** @var CgiExecuteEvent $event */
287290
$event = $this->eventDispatcher->dispatch(
288291
new CgiExecuteEvent('cgi.run.student-execute.pre', $request)
289292
);

src/ExerciseRunner/CliRunner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ private function doVerify(array $args, Input $input)
178178
$args = new ArrayObject($args);
179179

180180
try {
181+
/** @var CliExecuteEvent $event */
181182
$event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.reference-execute.pre', $args));
182183
$solutionOutput = $this->executePhpFile(
183184
$this->exercise->getSolution()->getEntryPoint(),
@@ -190,6 +191,7 @@ private function doVerify(array $args, Input $input)
190191
}
191192

192193
try {
194+
/** @var CliExecuteEvent $event */
193195
$event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.student-execute.pre', $args));
194196
$userOutput = $this->executePhpFile($input->getArgument('program'), $event->getArgs(), 'student');
195197
} catch (CodeExecutionException $e) {

0 commit comments

Comments
 (0)