src/Type/MessageType.php
public function guard($value, Field $field)
    {
        /** @var Message $value */
        Assertion::isInstanceOf($value, Message::class, null, $field->getName());

        $classNames = $field->getAnyOfClassNames();
        if (empty($classNames)) {
            // means it can be "any message"
            return;
        }

        foreach ($classNames as $className) {
            if ($value instanceof $className) {
                return;
            }
        }

        Assertion::true(
            false,
            sprintf(
                'Field [%s] must be an instance of at least one of: %s.',
                $field->getName(),
                implode(',', $classNames)
            ),
            $field->getName()
        );
    }
public function guard($value, Field $field)
    {
        /** @var Message $value */
        Assertion::isInstanceOf($value, Message::class, null, $field->getName());

        $classNames = $field->getAnyOfClassNames();
        if (empty($classNames)) {
            // means it can be "any message"
            return;
        }

        foreach ($classNames as $className) {
            if ($value instanceof $className) {
                return;
            }
        }

        Assertion::true(
            false,
            sprintf(
                'Field [%s] must be an instance of at least one of: %s.',
                $field->getName(),
                implode(',', $classNames)
            ),
            $field->getName()
        );
    }
public function guard ( $ value , Field $ field ) { /** @var Message $value */ Assertion :: isInstanceOf ( $ value , Message :: class , null , $ field -> getName ( ) ) ; $ classNames = $ field -> getAnyOfClassNames ( ) ; if ( empty ( $ classNames ) ) { // means it can be "any message" return ; } foreach ( $ classNames as $ className ) { if ( $ value instanceof $ className ) { return ; } } Assertion :: true ( false , sprintf ( 'Field [%s] must be an instance of at least one of: %s.' , $ field -> getName ( ) , implode ( ',' , $ classNames ) ) , $ field -> getName ( ) ) ; }
{@inheritdoc}
{