Skip to content

The phpcbf tool returns exit code 2 on "No fixable errors" success in v4.0.0Β #1272

@donatj

Description

@donatj

Describe the bug

Excuse me if this is intentional, but it's kind of weird / annoying.

Prior to 4.0.0 on "No fixable errors were found" phpcbf would return a success exit code of 0

Image

With the release of 4.0.0 phpcbf now seems to return an exit code of 2 on "No fixable errors"

Image

It's frankly kind of weird to return a 2 on success, and it breaks our automations. That's fixable, but I want to make sure that this is an intentional change before I fix it on our side.

Code sample

vendor/bin/phpcbf ; echo 'exit code ' $?

Custom ruleset

N/A

To reproduce

Steps to reproduce the behavior:

  1. Run phpcbf with no fixes made
  2. Examine exit code

Expected behavior

Exit code 0

Versions (please complete the following information)

Operating System macOS 15.6.1
PHP version 8.3
PHP_CodeSniffer version 4.0.0
Standard custom
Install type Composer local

Additional context

Add any other context about the problem here.

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • I have read the Contribution Guidelines and this is not a support question.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the 4.x branch of PHP_CodeSniffer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions