PHP 8.2.30
Preview: CallbackValidator.php Size: 2.42 KB
/opt/cloudlinux/alt-php53/root/usr/share/pear/Symfony/Component/Validator/Constraints/CallbackValidator.php

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;

/**
 * Validator for Callback constraint
 *
 * @author Bernhard Schussek <bschussek@gmail.com>
 *
 * @api
 */
class CallbackValidator extends ConstraintValidator
{
    /**
     * {@inheritDoc}
     */
    public function validate($object, Constraint $constraint)
    {
        if (null === $object) {
            return;
        }

        if (null !== $constraint->callback && null !== $constraint->methods) {
            throw new ConstraintDefinitionException(
                'The Callback constraint supports either the option "callback" ' .
                'or "methods", but not both at the same time.'
            );
        }

        // has to be an array so that we can differentiate between callables
        // and method names
        if (null !== $constraint->methods && !is_array($constraint->methods)) {
            throw new UnexpectedTypeException($constraint->methods, 'array');
        }

        $methods = $constraint->methods ?: array($constraint->callback);

        foreach ($methods as $method) {
            if (is_array($method) || $method instanceof \Closure) {
                if (!is_callable($method)) {
                    throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
                }

                call_user_func($method, $object, $this->context);
            } else {
                if (!method_exists($object, $method)) {
                    throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist', $method));
                }

                $reflMethod = new \ReflectionMethod($object, $method);

                if ($reflMethod->isStatic()) {
                    $reflMethod->invoke(null, $object, $this->context);
                } else {
                    $reflMethod->invoke($object, $this->context);
                }
            }
        }
    }
}

Directory Contents

Dirs: 1 × Files: 90

Name Size Perms Modified Actions
- drwxr-xr-x 2024-03-03 22:55:08
Edit Download
1.09 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.22 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.52 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.14 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
511 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
775 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.61 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.42 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
699 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
3.97 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.08 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.87 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.73 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.14 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.48 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
520 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.25 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.82 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
522 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.25 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
514 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
522 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
510 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.25 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
584 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.98 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
489 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
588 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
559 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.07 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.45 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
511 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
797 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.53 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
6.11 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
497 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
516 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
631 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
610 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
630 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
399 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
479 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.92 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
523 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
598 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.91 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
5.64 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.99 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.64 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.29 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.86 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
578 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.80 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
522 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.25 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.54 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.21 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
491 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
510 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
625 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
604 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
518 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.24 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
476 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.90 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
518 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
766 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
496 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
597 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
530 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
604 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
516 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
728 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
509 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
929 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
404 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.06 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.38 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
2.39 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.24 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
404 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
514 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.21 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
509 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
821 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
774 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
1.39 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
560 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download
3.59 KB lrw-r--r-- 2019-12-18 11:20:44
Edit Download
907 B lrw-r--r-- 2019-12-18 11:20:44
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).