Skip to content

[#473] Refactor console termination to explicit return flow - #478

Merged
armanist merged 1 commit into
quantum-php:masterfrom
armanist:issue/473-console-termination-refactor
Apr 29, 2026
Merged

armanist merged 1 commit into
quantum-php:masterfrom
armanist:issue/473-console-termination-refactor

Conversation

@armanist

@armanist armanist commented Apr 29, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #473

Summary by CodeRabbit

  • Refactor

    • Simplified console application startup and command execution flow, streamlining how exit codes are processed and returned.
  • Tests

    • Added test coverage to verify console exit codes are correctly propagated during command execution.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The ConsoleAppAdapter::start() method removes exception-based error handling by eliminating the try/catch block for StopExecutionException. It now directly returns the exit code from the Symfony console application's run() method, falling back to ExitCode::SUCCESS when the result is falsy. The prior behavior of catching the exception and calling stop() has been removed.

Changes

Cohort / File(s) Summary
Console Adapter Implementation
src/App/Adapters/ConsoleAppAdapter.php
Removed StopExecutionException import and try/catch block; replaced with direct return-based flow that propagates exit codes from application->run() without exception handling.
Console Adapter Tests
tests/Unit/App/Adapters/ConsoleAppAdapterTest.php
Added new test testConsoleAppAdapterReturnsNonZeroExitCode() that validates non-zero exit codes (e.g., 2) from Symfony console are properly propagated by the adapter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Away with catches, no more throws!
Direct returns are how it goes,
Exit codes flowing crystal-clear,
The console path is bright and dear! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: refactoring console termination from exception-driven flow to explicit return flow, directly matching the core PR objective.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #473: removes StopExecutionException catch, implements explicit return flow in ConsoleAppAdapter::start(), preserves exit code semantics, and includes test validation.
Out of Scope Changes check ✅ Passed All changes are in-scope: ConsoleAppAdapter.php refactoring aligns with issue requirements, and the new test directly validates the refactored return-based exit code flow.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.11%. Comparing base (12648d7) to head (1000fdb).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #478      +/-   ##
============================================
- Coverage     83.19%   83.11%   -0.09%     
+ Complexity     2905     2904       -1     
============================================
  Files           251      251              
  Lines          7660     7658       -2     
============================================
- Hits           6373     6365       -8     
- Misses         1287     1293       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/Unit/App/Adapters/ConsoleAppAdapterTest.php (1)

51-63: Optional: extract repeated adapter/application mock wiring into a helper.

The mock setup here duplicates the pattern from setUp(). A small helper (e.g., makeConsoleAdapterWithRunCode(int $code)) would reduce repetition.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Unit/App/Adapters/ConsoleAppAdapterTest.php` around lines 51 - 63,
Tests repeat the same ConsoleAppAdapter and Application mock wiring in
ConsoleAppAdapterTest (creating Application mock, stubbing getName/run, creating
a partial ConsoleAppAdapter, stubbing createApplication, then calling
__construct) which duplicates setUp; extract that into a helper method (e.g.,
makeConsoleAdapterWithRunCode(int $code) or buildConsoleAdapterMock) inside
ConsoleAppAdapterTest that returns a preconfigured ConsoleAppAdapter instance or
the pair of mocks; update the test to call this helper instead of repeating the
mock setup and keep references to createApplication, __construct,
Application::getName, and Application::run so locating/integrating the helper is
straightforward.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/Unit/App/Adapters/ConsoleAppAdapterTest.php`:
- Around line 51-63: Tests repeat the same ConsoleAppAdapter and Application
mock wiring in ConsoleAppAdapterTest (creating Application mock, stubbing
getName/run, creating a partial ConsoleAppAdapter, stubbing createApplication,
then calling __construct) which duplicates setUp; extract that into a helper
method (e.g., makeConsoleAdapterWithRunCode(int $code) or
buildConsoleAdapterMock) inside ConsoleAppAdapterTest that returns a
preconfigured ConsoleAppAdapter instance or the pair of mocks; update the test
to call this helper instead of repeating the mock setup and keep references to
createApplication, __construct, Application::getName, and Application::run so
locating/integrating the helper is straightforward.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2b34042-ea1c-4267-975e-8aeb098ae4b7

📥 Commits

Reviewing files that changed from the base of the PR and between 12648d7 and 1000fdb.

📒 Files selected for processing (2)
  • src/App/Adapters/ConsoleAppAdapter.php
  • tests/Unit/App/Adapters/ConsoleAppAdapterTest.php

@armanist
armanist requested a review from andrey-smaelov April 29, 2026 08:01
@armanist armanist added the enhancement New feature or request label Apr 29, 2026
@armanist armanist added this to the 3.0.0 milestone Apr 29, 2026
@armanist
armanist merged commit d8da24e into quantum-php:master Apr 29, 2026
6 of 7 checks passed
@armanist
armanist deleted the issue/473-console-termination-refactor branch April 29, 2026 08:19
@coderabbitai coderabbitai Bot mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor ConsoleAppAdapter termination flow away from stop()

2 participants