guess example



            if ($parent instanceof self || $parent instanceof TemplateWrapper) {
                return $this->parents[$parent->getSourceContext()->getName()] = $parent;
            }

            if (!isset($this->parents[$parent])) {
                $this->parents[$parent] = $this->loadTemplate($parent);
            }
        } catch (LoaderError $e) {
            $e->setSourceContext(null);
            $e->guess();

            throw $e;
        }

        return $this->parents[$parent];
    }

    protected function doGetParent(array $context)
    {
        return false;
    }

    
$tmpGuessers[] = $guesser->guessers;
            } else {
                $tmpGuessers[] = [$guesser];
            }
        }

        $this->guessers = array_merge([], ...$tmpGuessers);
    }

    public function guessType(string $class, string $property): ?TypeGuess
    {
        return $this->guess(static fn ($guesser) => $guesser->guessType($class$property));
    }

    public function guessRequired(string $class, string $property): ?ValueGuess
    {
        return $this->guess(static fn ($guesser) => $guesser->guessRequired($class$property));
    }

    public function guessMaxLength(string $class, string $property): ?ValueGuess
    {
        return $this->guess(static fn ($guesser) => $guesser->guessMaxLength($class$property));
    }

    
class ValidatorTypeGuesser implements FormTypeGuesserInterface
{
    private MetadataFactoryInterface $metadataFactory;

    public function __construct(MetadataFactoryInterface $metadataFactory)
    {
        $this->metadataFactory = $metadataFactory;
    }

    public function guessType(string $class, string $property): ?TypeGuess
    {
        return $this->guess($class$property$this->guessTypeForConstraint(...));
    }

    public function guessRequired(string $class, string $property): ?ValueGuess
    {
        // If we don't find any constraint telling otherwise, we can assume         // that a field is not required (with LOW_CONFIDENCE)         return $this->guess($class$property$this->guessRequiredForConstraint(...), false);
    }

    public function guessMaxLength(string $class, string $property): ?ValueGuess
    {
        
Home | Imprint | This part of the site doesn't use cookies.