Scrutinizer

This commit is contained in:
oleibman
2025-04-06 20:12:01 -07:00
parent 1da177e0d3
commit 6cec624f6a
3 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('vendor', 'docs', '.git', '.github')
->exclude(['vendor', 'docs', '.git', '.github'])
->notPath('src/PhpSpreadsheet/Writer/ZipStream3.php')
->in(__DIR__);
+9 -4
View File
@@ -8,7 +8,7 @@
*
* This will help us slowly migrate away from PHPDoc typing to PHP native typing.
*/
function checkPhpDocTypes(): void
function checkPhpDocTypes(): int
{
$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);
@@ -19,11 +19,16 @@ function checkPhpDocTypes(): void
...$returns[0],
];
if ($errors) {
if (!empty($errors)) {
echo 'PHP native types must be used instead of PHPDoc types (without comments), for the following lines:' . PHP_EOL . PHP_EOL;
echo implode(PHP_EOL, $errors) . PHP_EOL;
exit(1);
return 1;
}
return 0;
}
checkPhpDocTypes();
if (checkPhpDocTypes()) {
exit(1);
}
+1 -1
View File
@@ -46,7 +46,7 @@
],
"scripts": {
"check": [
"php ./bin/check-phpdoc-types",
"php bin/check-phpdoc-types.php",
"phpcs samples/ src/ tests/ --report=checkstyle",
"phpcs samples/ src/ tests/ --standard=PHPCompatibility --runtime-set testVersion 8.0- --exclude=PHPCompatibility.Variables.ForbiddenThisUseContexts -n",
"php-cs-fixer fix --ansi --dry-run --diff",