[php-src] Issue #19555: getopt with required value should not assign the next --opt as value, if no value provided
| From: | kkmuffme | Date: | Fri, 22 Aug 2025 14:54:16 +0000 |
| Subject: | [php-src] Issue #19555: getopt with required value should not assign the next --opt as value, if no value provided | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250605@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19555
Author: kkmuffme
### Description
The following code:
php opts.php --foo --bar="hello"
```php
<?php
$longopts = array( 'foo:' );
$options = getopt('', $longopts);
var_dump($options);
```
Resulted in this output:
```
array(1) {
["foo"]=>
string(11) "--bar=hello"
}
```
But I expected this output instead:
```
array(1) {
["foo"]=>
string(0) ""
}
```
### PHP Version
```plain
PHP 8.3.24
```
### Operating System
_No response_