This commit is contained in:
2025-02-04 12:40:43 +03:00
parent 4bcb4c60dd
commit 50343d5a87
372 changed files with 9019 additions and 6684 deletions

View File

@@ -2,12 +2,6 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [4.0.0] - 2025-02-07
### Removed
* This component is no longer supported on PHP 8.2
## [3.0.2] - 2024-07-03
### Changed
@@ -48,7 +42,6 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* Initial release
[4.0.0]: https://github.com/sebastianbergmann/cli-parser/compare/3.0...main
[3.0.2]: https://github.com/sebastianbergmann/cli-parser/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/sebastianbergmann/cli-parser/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/sebastianbergmann/cli-parser/compare/2.0...3.0.0

View File

@@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2020-2025, Sebastian Bergmann
Copyright (c) 2020-2024, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,4 +1,4 @@
[![Latest Stable Version](https://poser.pugx.org/sebastian/cli-parser/v)](https://packagist.org/packages/sebastian/cli-parser)
[![Latest Stable Version](https://poser.pugx.org/sebastian/cli-parser/v/stable.png)](https://packagist.org/packages/sebastian/cli-parser)
[![CI Status](https://github.com/sebastianbergmann/cli-parser/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/cli-parser/actions)
[![codecov](https://codecov.io/gh/sebastianbergmann/cli-parser/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/cli-parser)

View File

@@ -15,17 +15,16 @@
"issues": "https://github.com/sebastianbergmann/cli-parser/issues",
"security": "https://github.com/sebastianbergmann/cli-parser/security/policy"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.3"
"php": ">=8.2"
},
"require-dev": {
"phpunit/phpunit": "^12.0-dev"
"phpunit/phpunit": "^11.0"
},
"config": {
"platform": {
"php": "8.3.0"
"php": "8.2.0"
},
"optimize-autoloader": true,
"sort-packages": true
@@ -37,7 +36,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "4.0-dev"
"dev-main": "3.0-dev"
}
}
}

View File

@@ -19,6 +19,7 @@ use function current;
use function explode;
use function is_array;
use function is_int;
use function is_string;
use function key;
use function next;
use function preg_replace;
@@ -41,7 +42,7 @@ final class Parser
* @throws RequiredOptionArgumentMissingException
* @throws UnknownOptionException
*
* @return array{0: list<array{0: string, 1: ?string}>, 1: list<string>}
* @return array{0: list<array{0: non-empty-string, 1: ?non-empty-string}>, 1: list<non-empty-string>}
*/
public function parse(array $argv, string $shortOptions, ?array $longOptions = null): array
{
@@ -110,8 +111,8 @@ final class Parser
}
/**
* @param list<array{0: string, 1: ?string}> $options
* @param list<string> $argv
* @param list<array{0: non-empty-string, 1: ?non-empty-string}> $options
* @param list<string> $argv
*
* @throws RequiredOptionArgumentMissingException
*/
@@ -141,6 +142,8 @@ final class Parser
throw new RequiredOptionArgumentMissingException('-' . $option);
}
assert(is_string($optionArgument));
next($argv);
}
}
@@ -150,9 +153,9 @@ final class Parser
}
/**
* @param list<string> $longOptions
* @param list<array{0: string, 1: ?string}> $options
* @param list<string> $argv
* @param list<string> $longOptions
* @param list<array{0: non-empty-string, 1: ?non-empty-string}> $options
* @param list<string> $argv
*
* @throws AmbiguousOptionException
* @throws OptionDoesNotAllowArgumentException