Skip to content

php/phpstan, php/phpcs: fail when the tool finds errors in send-to-file mode - #53

Merged
AntonioCS merged 1 commit into
mainfrom
fix/phpstan-phpcs-exit-code
Sep 11, 2026
Merged

AntonioCS merged 1 commit into
mainfrom
fix/phpstan-phpcs-exit-code

Conversation

@AntonioCS

Copy link
Copy Markdown
Owner

Fixes #52.

make php/phpstan/analyse and make php/phpcs/check appended || true after the output redirect in send-to-file mode, so the target exited 0 whether the tool passed or found errors — the output file was the only signal, and nothing about a target named analyse/check says so.

Change

  • modules/php/phpstan/phpstan.mk:36 and modules/php/phpcs/phpcs.mk:38: keep the > file 2>&1 redirect, drop || true. The exit code now propagates, matching the non-file path.
  • CHANGELOG entry under 3.0.1 / Fixed.

Verification

Proof in #52 (probe file with a return-type error → exit 0 + [ERROR] Found 1 error; removed → exit 0 + [OK]). After this change the same probe makes the target exit non-zero while the output file still holds the report. Behaviour on the non-file path is unchanged.

Consumer note

CI in the consuming repos calls phpstan directly and was never masked; what this fixes is anyone running the make target and trusting $?. In compression_api phpcs runs nowhere else, so that target was the only gate and could not fail.

…e mode

Both targets appended '|| true' after the output redirect, so 'make
php/phpstan/analyse' and 'make php/phpcs/check' exited 0 whether the tool
passed or found errors; the output file was the only signal. Keep the
redirect, drop the swallow, so the exit code matches the non-file path.

Fixes #52.
@AntonioCS
AntonioCS merged commit 307e07a into main Sep 11, 2026
1 check passed
@AntonioCS
AntonioCS deleted the fix/phpstan-phpcs-exit-code branch September 11, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

php/phpstan/analyse and php/phpcs/check exit 0 when the tool finds errors (|| true in send-to-file mode)

1 participant