diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 9be2934cd..8409a17b0 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,7 +1,7 @@ exclude('vendor', 'docs', '.git', '.github') + ->exclude(['vendor', 'docs', '.git', '.github']) ->notPath('src/PhpSpreadsheet/Writer/ZipStream3.php') ->in(__DIR__); diff --git a/bin/check-phpdoc-types.php b/bin/check-phpdoc-types.php index b28c25331..1c620ea73 100755 --- a/bin/check-phpdoc-types.php +++ b/bin/check-phpdoc-types.php @@ -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); +} diff --git a/composer.json b/composer.json index 74fbc97ed..bf03b9a79 100644 --- a/composer.json +++ b/composer.json @@ -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",