Hey guys-

I don't care for the constructor for the Constraint (https://
github.com/fabpot/symfony/blob/master/src/Symfony/Component/Validator/
Constraint.php) class. It takes one argument ($options), which can
have various effects:

 * If it's an unindexed array, it iterates through and sets properties
on the Constraint object based on each array key. That makes for a
flexible "options" functionality that uses true properties. It sucks
for IDE hinting, but it's helpful overall.

 * If $options is non-null (but not an unindexed array), Constraint
looks for a defaultOption() method on itself, which returns a string
property name. The value of $options is then set on that property.

I don't see the purpose for the second bullet. Why not override the
Constraint constructor in individual constraints if you'd like the
first argument (or second argument) to specifically set a property?
This would make type-hinting more helpful. If you look at the Choice
constrain, it's not terribly obvious how to use it. What if it looked
like this instead?

public function __construct($choices, $options)
{
    $this->choices = $choices;

    parent::__construct($options);
}

Thoughts?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to