1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace hanneskod\readmetester\Utils; |
||
6 | |||
7 | use hanneskod\readmetester\Exception\InvalidPhpCodeException; |
||
8 | |||
9 | final class Loader |
||
10 | { |
||
11 | /** @var array<string, bool> */ |
||
12 | private static array $loaded = []; |
||
13 | |||
14 | public static function loadRaw(string $code): mixed |
||
0 ignored issues
–
show
|
|||
15 | { |
||
16 | return eval($code); |
||
0 ignored issues
–
show
|
|||
17 | } |
||
18 | |||
19 | /** @throws InvalidPhpCodeException on php error in code */ |
||
20 | public static function load(string $code): mixed |
||
21 | { |
||
22 | try { |
||
23 | return self::loadRaw($code); |
||
24 | } catch (\Throwable $exception) { |
||
25 | throw new InvalidPhpCodeException($exception->getMessage(), $code); |
||
26 | } |
||
27 | } |
||
28 | |||
29 | public static function loadOnce(string $code): void |
||
30 | { |
||
31 | $key = md5($code); |
||
32 | |||
33 | if (!isset(self::$loaded[$key])) { |
||
34 | self::$loaded[$key] = true; |
||
35 | self::load($code); |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths