Skip to content

fix: resolve TypeError in CLIRequest::parseCommand when argv is missing#10415

Open
gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix/cli-request-argv
Open

fix: resolve TypeError in CLIRequest::parseCommand when argv is missing#10415
gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix/cli-request-argv

Conversation

@gr8man

@gr8man gr8man commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description
In environments where $_SERVER['argv'] is not populated or explicitly set to null (e.g., during testing or non-standard executions), instantiating CLIRequest throws a TypeError: array_shift(): Argument #1 ($array) must be of type array, null given on modern PHP versions.

This PR resolves the issue by defaulting $args to an empty array before calling array_shift(). A corresponding unit test testParseCommandWithMissingArgv has been added to CLIRequestTest to ensure the class initializes properly under these conditions without throwing an error.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

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.

1 participant