Skip to content

Add passthrough arguments to PHP binary via -- separator#90

Merged
swissspidy merged 12 commits intomainfrom
copilot/add-passthrough-args-support
Mar 12, 2026
Merged

Add passthrough arguments to PHP binary via -- separator#90
swissspidy merged 12 commits intomainfrom
copilot/add-passthrough-args-support

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

Implementation Plan: Passthrough Arguments via --

  • Explore repository structure and understand current implementation
  • Modify Server_Command.php to capture and handle passthrough arguments after --
  • Update command documentation with the new passthrough feature
  • Add Behat tests to verify passthrough arguments work correctly
  • Address review feedback:
    • Update test to actually verify the passthrough arg was applied (outputs memory_limit value)
    • Remove dead code (-- check in loop), simplify with str_repeat + array_merge
    • Add @param annotations for $args and $assoc_args
Original prompt

This section details on the original issue you should resolve

<issue_title>Passthrough args via --?</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing

I want to load Xdebug module into the web server via php -S -dzend_extension=xdebug.so.

Describe the solution you'd like

wp server could pass through additional arguments to php after -- argument.

Example: wp server --docroot=public -- -dzend_extension=xdebug.so

Doing this via wp server --config argument is problematic, because I want to define universally usable commands centrally in composer.json scripts. Due to variety of INI configuration file locations on user's system, which we actually don't want to replace, this doesn't seem to be achievable with a single --config argument.</issue_description>

Comments on the Issue (you are @copilot in this section)

@schlessera Sounds like a reasonable use case.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Nov 10, 2025
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for passthrough args via '--' in wp server Add passthrough arguments to PHP binary via -- separator Nov 10, 2025
Copilot AI requested a review from swissspidy November 10, 2025 18:46
@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Server_Command.php 0.00% 12 Missing ⚠️
server-command.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy requested a review from Copilot November 10, 2025 20:59

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review November 10, 2025 21:04
@swissspidy swissspidy requested a review from a team as a code owner November 10, 2025 21:04
@swissspidy swissspidy added the command:server Related to 'server' command label Nov 10, 2025
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy swissspidy added this to the 2.0.17 milestone Jan 22, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy marked this pull request as draft February 23, 2026 18:41
@swissspidy swissspidy marked this pull request as ready for review March 12, 2026 13:07
@swissspidy swissspidy requested a review from Copilot March 12, 2026 13:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

$cmd_args[] = $assoc_args['config'];
$cmd_args[] = Utils\extract_from_phar( $router_path );

$cmd = Utils\esc_cmd( $cmd_format, ...$cmd_args );
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Utils\esc_cmd( $cmd_format, ...$cmd_args ) uses argument unpacking (...), which is only available starting with PHP 5.6. This package explicitly supports PHP 5.4+ (see the server-command.php version check / feature tag), so this will cause a parse error on PHP 5.4/5.5. Use a PHP 5.4-compatible approach to pass a dynamic argument list (e.g., call_user_func_array() with the format string prepended to the args array).

Suggested change
$cmd = Utils\esc_cmd( $cmd_format, ...$cmd_args );
$esc_cmd_args = $cmd_args;
array_unshift( $esc_cmd_args, $cmd_format );
$cmd = call_user_func_array( 'WP_CLI\Utils\esc_cmd', $esc_cmd_args );

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot This is incorrect. We require PHP 7.2+. Remove that check from server-command.php

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 820f666. Removed the before_invoke PHP 5.4 version check from server-command.php and updated the @require-php-5.4 Behat feature tag to @require-php-7.2 to match the actual requirement.

* @when before_wp_load
*
* @param array<string> $args Positional arguments passed through to the PHP binary.
* @param array{host: string, port: string, docroot?: string, config?: string} $assoc_args Associative arguments passed to the command.
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The PHPDoc array-shape for $assoc_args doesn't match the actual values used in this method: port is an int by default, and both docroot and config can be false (see $defaults). With phpstan.neon.dist no longer suppressing missing types, this mismatch can lead to incorrect static analysis results. Update the PHPDoc to reflect the real types (e.g., port: int|string, docroot: string|false, config: string|false).

Suggested change
* @param array{host: string, port: string, docroot?: string, config?: string} $assoc_args Associative arguments passed to the command.
* @param array{host: string, port: int|string, docroot?: string|false, config?: string|false} $assoc_args Associative arguments passed to the command.

Copilot uses AI. Check for mistakes.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy merged commit 0a85ebc into main Mar 12, 2026
60 checks passed
@swissspidy swissspidy deleted the copilot/add-passthrough-args-support branch March 12, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:server Related to 'server' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passthrough args via --?

3 participants