Skip to content

Add flags to Parser::parse() for options that take no value - #61

Merged
niden merged 1 commit into
3.0.xfrom
T60-parse-flags
Dec 4, 2026
Merged

niden merged 1 commit into
3.0.xfrom
T60-parse-flags

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:

Stacked on #59. Merge #59 first. GitHub then moves the base of this PR to 3.0.x.

  • parse(array $argv = [], array $flags = []). $flags lists the names of the options that take no value, without dashes. The flags apply only to that call.
  • --name value: a flag does not take value. value becomes a positional argument.
  • -abc value: each flag letter is true, and the other letters take value. If all letters are flags, value becomes a positional argument.
  • --name=value keeps the value, also for a flag.
  • Without $flags, the result is the same as in 2.x. All the current test cases pass with no change.
  • README section "Flags" and a CHANGELOG line.

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

Thanks

@niden niden added the enhancement New feature or request 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) T60-parse-flags (a5bff1e) +/-
Coverage 100.0% 100.0% 0.0%
Test Execution Time 1s 0s -1s
Details
  |                     | master (4b6c04c) | T60-parse-flags (a5bff1e) | +/-  |
  |---------------------|------------------|---------------------------|------|
  | Coverage            |           100.0% |                    100.0% | 0.0% |
  |   Files             |                1 |                         1 |    0 |
  |   Lines             |               71 |                        73 |   +2 |
+ |   Covered           |               71 |                        73 |   +2 |
+ | 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 mentioned this pull request Dec 4, 2026
4 tasks done
Base automatically changed from T58-parser-final to 3.0.x December 4, 2026 19:50
@niden niden mentioned this pull request Dec 4, 2026
2 of 4 tasks
@niden
niden merged commit 497eda8 into 3.0.x Dec 4, 2026
14 checks passed
@niden
niden deleted the T60-parse-flags branch December 4, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant