* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form; use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Exception\UnexpectedTypeException; class FormTypeGuesserChain implements FormTypeGuesserInterface { private $guessers = array(); /** * @param FormTypeGuesserInterface[] $guessers Guessers as instances of FormTypeGuesserInterface * * @throws UnexpectedTypeException if any guesser does not implement FormTypeGuesserInterface */ public function __construct($guessers) { if (!is_array($guessers) && !$guessers instanceof \Traversable) { throw new UnexpectedTypeException($guessers, 'array or Traversable'); } foreach ($guessers as $guesser) { if (!$guesser instanceof FormTypeGuesserInterface) { throw new UnexpectedTypeException($guesser, 'Symfony\Component\Form\FormTypeGuesserInterface'); } if ($guesser instanceof self) { $this->guessers = array_merge($this->guessers, $guesser->guessers); } else { $this->guessers[] = $guesser; } } } /** * {@inheritdoc} */ public function guessType($class, $property) { return $this->guess(function ($guesser) use ($class, $property) { return $guesser->guessType($class, $property); }); } /** * {@inheritdoc} */ public function guessRequired($class, $property) { return $this->guess(function ($guesser) use ($class, $property) { return $guesser->guessRequired($class, $property); }); } /** * {@inheritdoc} */ public function guessMaxLength($class, $property) { return $this->guess(function ($guesser) use ($class, $property) { return $guesser->guessMaxLength($class, $property); }); } /** * {@inheritdoc} */ public function guessPattern($class, $property) { return $this->guess(function ($guesser) use ($class, $property) { return $guesser->guessPattern($class, $property); }); } /** * Executes a closure for each guesser and returns the best guess from the * return values. * * @param \Closure $closure The closure to execute. Accepts a guesser * as argument and should return a Guess instance * * @return Guess|null The guess with the highest confidence */ private function guess(\Closure $closure) { $guesses = array(); foreach ($this->guessers as $guesser) { if ($guess = $closure($guesser)) { $guesses[] = $guess; } } return Guess::getBestGuess($guesses); } } __halt_compiler();----SIGNATURE:----UgfNLTgCWyOTtNqUCZEaJwYDxVFEESOsQJfvloNE4XwcfZLob7LVW+VmH35aSQnz+PK4x0YbT0HusFt52IwL3vTYVMGQG7dEBWuXzumlO901vUypZMXrcZbgJTW5fNYr1mL/ymFEVZnLfZ4oAZ8oKw0DgonYeg7kP40PBmPThaXcBCYQQhgrAC8pfR5QFoErc77WT6AppR5dn21dNYLpJp/50d5eMHontQimQf8hzAF/cYoGFEJZti/v69JESpAyvKg5iOdol1g2EqQpp/TH/dg/VdBfrXfUiN2BfgF0Gn5STtdMFFWtJPz1+szcrpjaKU011Co4lsKW6RsKuk6thqkq7HfvgPdJJf40XMUn44wzU+ldWvJA1JZrPb2er7i+9iKleOTvQEBgQSNr7JZbjb8J5tiLHlrKNyRBJNEtA7hIh9MbKUWu8m1gFfsGBvrj+GR9RI6LZQOr4idWKUtuwVeCgyrTs3sd1ALr7o5ke3ahNwEgjXpWs30BSunRL0OSAdnmNgwtdmaU/weGzViQwK73H+6MrfntqJ1kctRE050M6em629ZacPsO4Wpg2K3/WBXN55j+em9YYmO0Cy5X9aEM+GUy/LnzBzHkrOBEesX5mlSxnCP7L12BOZxEF0nEdb2BFk7SVnsYrOgPA/v50mEpCnvhDlAob+QYvFRUKI0=----ATTACHMENT:----OTgzNDc1MzI3NTA2NjY2MyA2OTI2MzQ4MjUwODczMDkyIDQyMTEzOTUzMTYxNzc0OA==