Better Typing in Test Members

Change "mixed" declarations to more accurate types in test members; in particular, change those that would be flagged if we were to run Phpstan at level 9 (we currently run level 8). I may or may not follow up with source code (over 700 level-9 problems remain for src), but, as with strict typing, there is no reason to avoid the effort for test members.

It was necessary to update some doc blocks in src to accommodate this change. However, no executable code is touched.
This commit is contained in:
oleibman
2024-01-05 01:43:50 -08:00
parent 43481c9deb
commit 3eedf9e2f0
130 changed files with 372 additions and 253 deletions
+4 -4
View File
@@ -10,9 +10,9 @@
*/
function checkPhpDocTypes(): void
{
$content = `git diff --cached` ?? `git diff` ?? `git show HEAD`;
preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+( \$\w+)?$~m', $content, $parameters);
preg_match_all('~^\+ +\* @return (mixed|string|int|float|bool|null|array|void|\?|\|)+$~m', $content, $returns);
$content = shell_exec('git diff --cached') ?? shell_exec('git diff') ?? shell_exec('git show HEAD');
preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+( \$\w+)?$~m', "$content", $parameters);
preg_match_all('~^\+ +\* @return (mixed|string|int|float|bool|null|array|void|\?|\|)+$~m', "$content", $returns);
$errors = [
...$parameters[0],
@@ -21,7 +21,7 @@ function checkPhpDocTypes(): void
if ($errors) {
echo 'PHP native types must be used instead of PHPDoc types (without comments), for the following lines:' . PHP_EOL . PHP_EOL;
echo join(PHP_EOL, $errors) . PHP_EOL;
echo implode(PHP_EOL, $errors) . PHP_EOL;
exit(1);
}
}