Skip to content

No Exception when defining type on flag #67

@pixlmint

Description

@pixlmint

This just took me forever to debug and I had to dig way too deep into the Code to figure out what the issue was.

I had this Code:

$webRequestSpecs->add('p|path', 'Path to request')
    ->isa('string');

And I kept getting this error: Invalid value for -p, --path. Requires a type String. even though I was passing the string it was looking for. What I managed to figure out after ~2 hours of debugging, was that my argument was being registered as a flag instead of a regular Argument, the thing that was missing was a colon (:) in the spec string.

However, because I added the ->isa('string'), it was still doing the type checking - but because it's a flag, there isn't any value to check for.

In my opinion, my ->isa('string') should have thrown an exception, since flags per definition cannot have types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions