khalyomede / khalyomede/command-parser

Parse definition should be checked

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Specifying wrong format for the argument of `CommandParser::parse()` will throw numerous general PHP exceptions.

**To Reproduce**
_command.php_
```php
CommandParser::parse(['arguments' => 'wrong', 'flags' => 'also wrong']);
```
```bash
php command.php
```
**Expected value**
```bash
Uncaught InvalidArgumentException: ...
```

**Actual value**
```bash
PHP Fatal error: Uncaught Khalyomede\Exception\NotEnoughArgumentsException: found 0 arguments, but the command requires 1 arguments in command-parser\src\CommandParser.php:200
Stack trace:
#0 command-parser\example\example-1.php(7): Khalyomede\CommandParser::parse(Array)
#1 {main}
thrown in command-parser\src\CommandParser.php on line 200

Fatal error: Uncaught Khalyomede\Exception\NotEnoughArgumentsException: found 0 arguments, but the command requires 1 arguments in command-parser\src\CommandParser.php:200
Stack trace:
#0 command-parser\example\example-1.php(7): Khalyomede\CommandParser::parse(Array)
#1 {main}
thrown in command-parser\src\CommandParser.php on line 200
```

**Version**
0.2.0

**Suggestions**

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with CommandParser::parse() in command-parser/src/CommandParser.php, especially the path around line 200, and reproduce the example from command.php with the malformed arguments and flags shown. Trace how the input is validated and compare the resulting exception with the requested InvalidArgumentException. Done means malformed parse definitions produce the expected exception instead of unrelated argument errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.