Skip to content

Commit c4c5bc0

Browse files
committed
Fix static issues
1 parent 7782da2 commit c4c5bc0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Check/FileComparisonCheck.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
namespace PhpSchool\PhpWorkshop\Check;
66

77
use InvalidArgumentException;
8+
use PhpSchool\PhpWorkshop\Exception\RuntimeException;
89
use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface;
910
use PhpSchool\PhpWorkshop\Exercise\ExerciseType;
11+
use PhpSchool\PhpWorkshop\Exercise\ProvidesSolution;
1012
use PhpSchool\PhpWorkshop\ExerciseCheck\FileComparisonExerciseCheck;
1113
use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck;
1214
use PhpSchool\PhpWorkshop\Input\Input;
@@ -32,7 +34,7 @@ public function getName(): string
3234
/**
3335
* Simply check that the file exists.
3436
*
35-
* @param ExerciseInterface $exercise The exercise to check against.
37+
* @param ExerciseInterface&ProvidesSolution $exercise The exercise to check against.
3638
* @param Input $input The command line arguments passed to the command.
3739
* @return ResultInterface The result of the check.
3840
*/
@@ -47,7 +49,7 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac
4749
$referenceFile = $exercise->getSolution()->getBaseDirectory() . '/' . ltrim($file, '/');
4850

4951
if (!file_exists($referenceFile)) {
50-
throw new Exception('Reference file does not exit');
52+
throw new RuntimeException(sprintf('File: "%s" does not exist in solution folder', $file));
5153
}
5254

5355
if (!file_exists($studentFile)) {
@@ -57,8 +59,8 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac
5759
);
5860
}
5961

60-
$actual = file_get_contents($studentFile);
61-
$expected = file_get_contents($referenceFile);
62+
$actual = (string) file_get_contents($studentFile);
63+
$expected = (string) file_get_contents($referenceFile);
6264

6365
if ($expected !== $actual) {
6466
return new FileComparisonFailure($this, $file, $expected, $actual);

src/ExerciseCheck/FileComparisonExerciseCheck.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
*/
1111
interface FileComparisonExerciseCheck
1212
{
13+
/**
14+
* @return array<string>
15+
*/
1316
public function getFilesToCompare(): array;
1417
}

0 commit comments

Comments
 (0)