55namespace PhpSchool \PhpWorkshop \Check ;
66
77use InvalidArgumentException ;
8+ use PhpSchool \PhpWorkshop \Exception \RuntimeException ;
89use PhpSchool \PhpWorkshop \Exercise \ExerciseInterface ;
910use PhpSchool \PhpWorkshop \Exercise \ExerciseType ;
11+ use PhpSchool \PhpWorkshop \Exercise \ProvidesSolution ;
1012use PhpSchool \PhpWorkshop \ExerciseCheck \FileComparisonExerciseCheck ;
1113use PhpSchool \PhpWorkshop \ExerciseCheck \FunctionRequirementsExerciseCheck ;
1214use 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 );
0 commit comments