php - Static method call VS dynamic method call in Respect\Validation -
when using respect\validation, found when rules called static method (using ::), last rule checked. however, when rules called dynamic method (using ->), whole rule chain checked.
below example. expect in both cases should return false because length rule not met. however, first line gives result of last rule (i.e. startswith()) in chain. why it?
phpstorm highlights dynamic method call , suggested use static.
var_dump( validator::stringtype()::length(5,10,true)::startswith('abc')->validate('abc test string longer 15 characters') ); // ==> true var_dump( validator::stringtype()->length(5,10,true)->startswith('abc')->validate('abc test string longer 15 characters') ); // ==> false
Comments
Post a Comment