Skip to content

Incorrect exit code handling for phpcbf #382

Description

@ADmad

Verified on latest main

  • I have confirmed this bug still occurs when built from the latest main branch.

PHPantom version / commit

0.10.0

Installation method

Pre-built binary from GitHub Releases

Operating system

Linux x86_64

Editor

Zed

Bug description

Using the "Format buffer" action (to auto format the current file) in Zed fails when phpcbf is used.

If the file has formatting issues running the action generates error:

Formatting failed: phpcbf exited with code 2 (stderr: )

Even when the file doesn't have any formatting errors Zed gives an error

Formatting failed: phpcbf exited with code 2 (stderr: No fixable errors were found)

This most likely stems from the fact that phpantom treats phpcbf's exit code 2 as an error

match status.code {
0 | 1 => Ok(formatted),
_ => Err(format!(
"phpcbf exited with code {} (stderr: {})",
status.code,
status.stderr.trim()
)),
}

The resolution would be to treat exit codes 0-2 as non errors.

Steps to reproduce

.

Error output or panic trace


.phpantom.toml

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions