Method visibility bug
allen05ren opened this issue · 5 comments
getLength()
and setLength()
visibility shold be public ?
zend-validator/src/StringLength.php
Lines 182 to 202 in 87e743d
Probably not: if they are unused, they should instead be dropped.
getLength() and setLength() visibility shold be public ?
Not needed, because the description of validator is:
This validator allows you to validate if a given string is between a defined length.
If you need a strict length, then set the min
and max
values to the same value:
$validator = new \Zend\Validator\StringLength(
[
'min' => 3,
'max' => 3,
]
);
var_dump($validator->isValid('foo')); // true
var_dump($validator->isValid('fo')); // false
var_dump($validator->isValid('foobar')); // false
@Ocramius
The methods are used in the method isValid
:
zend-validator/src/StringLength.php
Lines 220 to 227 in 87e743d
But the documentation is misleading here:
https://docs.zendframework.com/zend-validator/validators/string-length/#supported-options
The following options are supported for Zend\Validator\StringLength:
- encoding: Sets the ICONV encoding to use with the string.
- min: Sets the minimum allowed length for a string.
- max: Sets the maximum allowed length for a string.
- length: Holds the actual length of the string.
"Holds" is correct, but it can not be set or is public.
@froschdesign
Yes, i see. You are right, it can not be set or is public.