getTypeConstraint example

if (!$nullable && $type->isNullable()) {
                    $nullable = true;
                }
            }
            if (!$hasTypeConstraint) {
                if (1 === \count($builtinTypes)) {
                    if ($types[0]->isCollection() && \count($collectionValueType = $types[0]->getCollectionValueTypes()) > 0) {
                        [$collectionValueType] = $collectionValueType;
                        $this->handleAllConstraint($property$allConstraint$collectionValueType$metadata);
                    }

                    $metadata->addPropertyConstraint($property$this->getTypeConstraint($builtinTypes[0]$types[0]));
                } elseif ($scalar) {
                    $metadata->addPropertyConstraint($propertynew Type(['type' => 'scalar']));
                }
            }

            if (!$nullable && !$hasNotBlankConstraint && !$hasNotNullConstraint) {
                $metadata->addPropertyConstraint($propertynew NotNull());
            }
        }

        return $loaded;
    }
if (!$nullable && $type->isNullable()) {
                    $nullable = true;
                }
            }
            if (!$hasTypeConstraint) {
                if (1 === \count($builtinTypes)) {
                    if ($types[0]->isCollection() && \count($collectionValueType = $types[0]->getCollectionValueTypes()) > 0) {
                        [$collectionValueType] = $collectionValueType;
                        $this->handleAllConstraint($property$allConstraint$collectionValueType$metadata);
                    }

                    $metadata->addPropertyConstraint($property$this->getTypeConstraint($builtinTypes[0]$types[0]));
                } elseif ($scalar) {
                    $metadata->addPropertyConstraint($propertynew Type(['type' => 'scalar']));
                }
            }

            if (!$nullable && !$hasNotBlankConstraint && !$hasNotNullConstraint) {
                $metadata->addPropertyConstraint($propertynew NotNull());
            }
        }

        return $loaded;
    }
Home | Imprint | This part of the site doesn't use cookies.