Skip to content

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Feb 10, 2026

Summary

  • Make stderr parameter required in Console::execute and capture stderr separately.
  • Rename execute params to stdin/stdout/stderr and keep stdout-only output.
  • Update tests for new execute signature.

Testing

  • Not run (not requested).

Summary by CodeRabbit

  • New Features

    • Console execution now separates error and output streams for improved error handling and diagnostics.
  • Breaking Changes

    • Minimum PHP version requirement increased to 8.0+.

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Walkthrough

This pull request updates the minimum PHP version requirement from 7.4 to 8.0 and refactors the Console::execute() method's signature. The method previously accepted a single $output reference parameter that combined stdout and stderr; it now accepts two separate reference parameters: $stdout and $stderr. Internal variable handling is updated to track and accumulate stdout and stderr independently. All test invocations are updated to accommodate the new five-parameter signature with the additional stderr parameter.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update console execute stderr capture' directly describes the main change: modifying the Console::execute method to capture stderr separately.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/Console.php (3)

164-177: Redundant intermediate variable $outputContents.

$outputContents on line 170 is just an alias for $stdoutContents — the old code likely needed it to merge stdout+stderr, but now that they're separated, you can use $stdoutContents directly.

♻️ Suggested simplification
-            $stderr .= $stderrContents;
-
-            $outputContents = $stdoutContents;
-
-            if (isset($onProgress) && (! empty($outputContents))) {
-                $onProgress($outputContents, $process);
+            $stderr .= $stderrContents;
+
+            if (isset($onProgress) && (! empty($stdoutContents))) {
+                $onProgress($stdoutContents, $process);
             }
 
-            $stdout .= $outputContents;
+            $stdout .= $stdoutContents;

179-183: Resource leak on timeout: pipes and process handle are not closed.

When the timeout fires, proc_terminate is called but pipes[1], pipes[2], and pipes[3] are never closed, and proc_close is never called. This is pre-existing, but now that the method is being refactored, it would be a good time to fix it.

🛡️ Suggested fix
             if ($timeout > 0 && \time() - $start > $timeout) {
                 \proc_terminate($process, 9);
+                \fclose($pipes[1]);
+                \fclose($pipes[2]);
+                \fclose($pipes[3]);
+                \proc_close($process);
 
                 return 1;
             }

185-193: pipes[3] (status fd) is never closed on normal exit.

Lines 186–187 close pipes[1] and pipes[2], but pipes[3] is not closed before proc_close. This leaks a file descriptor. Pre-existing, but straightforward to fix here.

🛡️ Suggested fix
                 \fclose($pipes[1]);
                 \fclose($pipes[2]);
+                \fclose($pipes[3]);
                 \proc_close($process);

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

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

@ChiragAgg5k ChiragAgg5k force-pushed the feature/console-stderr-capture branch from 59625fd to b55d01a Compare February 10, 2026 06:42
@loks0n loks0n merged commit d298e43 into utopia-php:main Feb 10, 2026
7 checks passed
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.

2 participants