zendframework/zend-validator

Regex validator constructor parameter type issue

alextartan opened this issue · 4 comments

The current docblock lists @param string|Traversable $pattern, but arrays are accepted as well.

What should it receive to avoid any warnings?

I'm currently using:

new Regex(
    new \ArrayIterator(
        [
            'pattern'  => 'something', 
            'messages' => [
                Regex::NOT_MATCH => 'somethingElse'
            ]
        ]
    )
)

But it seems a bit of an overhead to wrap an array in an arrayIterator just to avoid a warning. I can. of course, extend the Regex validator and fix this in my codebase, but i figure i'm not the only one bumping into this isuue.

Since the $pattern parameter is passed to parent::__construct($param) which does accept @param array|Traversable $options, I'm guessing Regex should accept array as well

@alextartan

I'm guessing Regex should accept array as well

It accepts also an array. Only the DocBlock is missing this hint.

@froschdesign I know. I made this Pull Request to fix the docblock #198

@froschdesign any news on this?

as #198 merged, it can be closed.