* * 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:----OjULTYrw3hlA01umPwggD1RP5h5FlN7UBsiOcANH0Y+EXYFggL4twlMReFAp3r15pqkaJK3DAXaQCmQNP8GeMjCYPqULEtLD10hAYp3BTbKNhiMP3hIG+a/l5tz4buC6axxMXUjiJ9bwW/QCFGipQqIynRyo/UGDALA8ecBdYpxy/W8rvKE7uX/lWZ/QDC8mrQ/Cuko/Bc84sua+KGV03/FvGcFeI+9P3mBQXBh+IqlyGwwokCNIZQ99yIgWnPRlYfkM8tJe2Q8bpzdjkiRmCudTUWcVoDl7aywf2gJ7ouWOQTFcTAjI0E1Yb78zS3brFs0Hel6aka9cwVWkFMzGqEI7lx+GrnUK7MgtufkBFzTL3wKO6S7iQNCwC3Ae+/PX54l9wiguLUrneVMRA//M95BL09XTZpdpSx4N1K4AQNem1WYShxWK88fW+W8P6z+MnqMTJGQ1oe19qZYm1XU0csuNIsCJ1ZstdZo1LYty89DYZd+8akiyP9PrEYUceywUJ4j+LoPWNkwvJcGHJUhhFEsdZx0BQ8WKEs4nclxcQIcDNXuqPVhaax1cUBOc/ivh/57CMuOPX4SWHvuR/SIfWSkwiKLAuqGKk+GQYcu/SVRz++5ceUKhcaNbwSeNApvD1wT/eSz5ViQ+EYz7jNpm7iW/nJdJFHTrWcHeQPLcubU=----ATTACHMENT:----NjM1OTQ2MDk2MzEwMTY1NCA1Njc4NjYwNDkxNDA3NjE4IDgzNDEwMjQwNTIxMzAwMTc=