Conditions | 2 |
Paths | 2 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | #!/usr/bin/env php |
||
11 | function checkPhpDocTypes(): int |
||
12 | { |
||
13 | $content = shell_exec('git diff --cached') ?? shell_exec('git diff') ?? shell_exec('git show HEAD'); |
||
14 | preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+( \$\w+)?$~m', "$content", $parameters); |
||
15 | preg_match_all('~^\+ +\* @return (mixed|string|int|float|bool|null|array|void|\?|\|)+$~m', "$content", $returns); |
||
16 | |||
17 | $errors = [ |
||
18 | ...$parameters[0], |
||
19 | ...$returns[0], |
||
20 | ]; |
||
21 | |||
22 | if (!empty($errors)) { |
||
23 | echo 'PHP native types must be used instead of PHPDoc types (without comments), for the following lines:' . PHP_EOL . PHP_EOL; |
||
24 | echo implode(PHP_EOL, $errors) . PHP_EOL; |
||
25 | |||
26 | return 1; |
||
27 | } |
||
28 | |||
29 | return 0; |
||
30 | } |
||
35 |