Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ClassMetadata.php

function ClassMetadata::canCascade

1 call to ClassMetadata::canCascade()
ClassMetadata::addConstraint in vendor/symfony/validator/Mapping/ClassMetadata.php
If the constraint {@link Cascade} is added, the cascading strategy will be changed to {@link CascadingStrategy::CASCADE}.

File

vendor/symfony/validator/Mapping/ClassMetadata.php, line 487

Class

ClassMetadata
Default implementation of {@link ClassMetadataInterface}.

Namespace

Symfony\Component\Validator\Mapping

Code

private function canCascade(?\ReflectionType $type = null) : bool {
    if (null === $type) {
        return false;
    }
    if ($type instanceof \ReflectionIntersectionType) {
        foreach ($type->getTypes() as $nestedType) {
            if ($this->canCascade($nestedType)) {
                return true;
            }
        }
        return false;
    }
    if ($type instanceof \ReflectionUnionType) {
        foreach ($type->getTypes() as $nestedType) {
            if (!$this->canCascade($nestedType)) {
                return false;
            }
        }
        return true;
    }
    return $type instanceof \ReflectionNamedType && (\in_array($type->getName(), [
        'array',
        'null',
    ], true) || class_exists($type->getName()));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal