Skip to content

Conversation

fredden
Copy link
Member

@fredden fredden commented Aug 8, 2025

Description

When running phpcbf with a PHP file as input (eg, phpcbf < test.php), the exit code was not reported correctly. This pull request fixes that bug. For more details, see #1082.

Suggested changelog entry

Fixed exit code when phpcbf is processing STDIN

Related issues/external references

Fixes #1082

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution Guidelines.
  • I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
  • I have added tests to cover my changes.
  • I have verified that the code complies with the projects coding standards.
  • [Required for new sniffs] I have added XML documentation for the sniff.
  • I have opened a sister-PR in the documentation repository to update the Wiki.

@fredden
Copy link
Member Author

fredden commented Aug 8, 2025

@jrfnl how would you like to cover this change with tests?

@jrfnl
Copy link
Member

jrfnl commented Aug 8, 2025

how would you like to cover this change with tests?

I imagine it may be difficult to cover this change via the PHPUnit setup as it would require mocking STDIN. How about adding some tests to the bashunit E2E testsuite ?

@jrfnl jrfnl added this to the 4.0.0 milestone Aug 8, 2025
@jrfnl
Copy link
Member

jrfnl commented Aug 16, 2025

@fredden Just checking - will you have time over the next few days to add a few bashunit tests for STDIN handling ? Or would you like me to add something ?

@fredden
Copy link
Member Author

fredden commented Aug 17, 2025

I'm happy to update this, but I'm away at the moment. Earliest that I can pick this up again would be Wednesday/Thursday this week. I do have a bash script that I used for local development which will be trivial to convert into the format needed for bashunit.

If you want to land this before Friday, feel free to add some tests.

@fredden fredden force-pushed the issue-1082/exit-code-when-fixing-stdin branch from 4fed094 to 7bfebcc Compare August 21, 2025 23:09
@fredden fredden requested a review from jrfnl August 21, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants