Skip to content

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

Open
gr8man wants to merge 5 commits into
codeigniter4:developfrom
gr8man:fix/cli-request-argv
Open

fix: resolve TypeError in CLIRequest::parseCommand when argv is missing#10415
gr8man wants to merge 5 commits 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

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a changelog entry.

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Jul 19, 2026
@gr8man
gr8man requested a review from michalsn July 19, 2026 19:51
@gr8man
gr8man force-pushed the fix/cli-request-argv branch from 12b1309 to 4d247bc Compare July 19, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants