/** * Sets normalizers that are applied on resolved options. * * The normalizers should be closures with the following signature: * * <code> * function (Options $options, $value) * </code> * * The second parameter passed to the closure is the value of * the option. * * The closure should return the normalized value. * * @param array $normalizers An array of closures * * @return OptionsConfig This configuration instance */ public function setNormalizers(array $normalizers) { Options::validateNames($normalizers, $this->knownOptions, true); foreach ($normalizers as $option => $normalizer) { $this->defaultOptions->setNormalizer($option, $normalizer); } return $this; }
/** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testValidateNamesFailsIfNonExistingOptionsNamesAsKeys() { $options = array('one' => '1', 'foo' => 'bar'); Options::validateNames($options, array('one' => null, 'two' => null), true); }