Skip to content

[BUG]: An empty argument after an option gives a PHP warning - #67

Merged
niden merged 1 commit into
3.0.xfrom
T66-empty-argument
Dec 4, 2026
Merged

niden merged 1 commit into
3.0.xfrom
T66-empty-argument

Conversation

@niden

@niden niden commented Dec 4, 2026

Copy link
Copy Markdown
Member

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG

Small description of change:

  • handleArguments(): the look-ahead uses !str_starts_with($argv[$i + 1], '-') in place of $argv[$i + 1][0] !== '-', in two places. An empty token no longer gives Uninitialized string offset 0. The result does not change.
  • Two new parseProvider cases: --name '' and -n ''. Before the fix, PHPUnit reported the 2 warnings and the run failed (failOnWarning).
  • CHANGELOG line under Fixed.

Results in the PHP 8.3 container: 65 tests pass with no warnings, line coverage 100% (75/75), Infection MSI 100% and covered MSI 100% (120 mutants). PHPCS, PHPStan and PHP CS Fixer pass.

Thanks

@niden niden added the bug Something isn't working label Dec 4, 2026
@niden niden self-assigned this Dec 4, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Code Metrics Report

master (4b6c04c) T66-empty-argument (4e25fe5) +/-
Coverage 100.0% 100.0% 0.0%
Test Execution Time 1s 0s -1s
Details
  |                     | master (4b6c04c) | T66-empty-argument (4e25fe5) | +/-  |
  |---------------------|------------------|------------------------------|------|
  | Coverage            |           100.0% |                       100.0% | 0.0% |
  |   Files             |                1 |                            1 |    0 |
  |   Lines             |               71 |                           75 |   +4 |
+ |   Covered           |               71 |                           75 |   +4 |
+ | Test Execution Time |               1s |                           0s |  -1s |

Code coverage of files in pull request scope (100.0% → 100.0%, patch 100.0%)

Files Coverage +/- Patch Coverage Status
src/Parser.php 100.0% 0.0% 100.0% modified

Reported by octocov

@niden
niden merged commit 526e79e into 3.0.x Dec 4, 2026
14 checks passed
@niden
niden deleted the T66-empty-argument branch December 4, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant