3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface ValidatorInterfaceFirst { public function validate($value, $groups = null, $traverse = false, $deep = false); public function validateProperty($containingValue, $property, $groups = null); public function validatePropertyValue($containingValue, $property, $value, $groups = null); public function validateValue($value, $constraints, $groups = null); public function getMetadataFactory(); } interface ValidatorInterfaceSecond { public function validate($value, $constraints = null, $groups = null); public function validateProperty($object, $propertyName, $groups = null); public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); public function startContext(); public function inContext(ExecutionContextInterface $context); } class RecursiveValidator implements ValidatorInterfaceFirst, ValidatorInterfaceSecond { protected $contextFactory; protected $metadataFactory; protected $validatorFactory; protected $objectInitializers; public function __construct(ExecutionContextFactoryInterface $contextFactory, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = array()) { $this->contextFactory = $contextFactory; $this->metadataFactory = $metadataFactory; $this->validatorFactory = $validatorFactory; $this->objectInitializers = $objectInitializers; } public function startContext($root = null) { return new RecursiveContextualValidator( $this->contextFactory->createContext($this, $root), $this->metadataFactory, $this->validatorFactory, $this->objectInitializers ); } public function inContext(ExecutionContextInterface $context) { return new RecursiveContextualValidator( $context, $this->metadataFactory, $this->validatorFactory, $this->objectInitializers ); } public function getMetadataFor($object) { return $this->metadataFactory->getMetadataFor($object); } public function hasMetadataFor($object) { return $this->metadataFactory->hasMetadataFor($object); } public function validate($value, $groups = null, $traverse = false, $deep = false) { $numArgs = func_num_args(); if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) { $constraints = $groups; $groups = $traverse; } else { trigger_error('The Symfony\Component\Validator\ValidatorInterface::validate method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); $constraints = new Valid(array('traverse' => $traverse, 'deep' => $deep)); } return $this->startContext($value) ->validate($value, $constraints, $groups) ->getViolations(); } public function validateProperty($object, $propertyName, $groups = null) { return $this->startContext($object) ->validateProperty($object, $propertyName, $groups) ->getViolations(); } public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) { return $this->startContext(is_object($objectOrClass) ? $objectOrClass : $value) ->validatePropertyValue($objectOrClass, $propertyName, $value, $groups) ->getViolations(); } public function validateValue($value, $constraints, $groups = null) { trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); return $this->validate($value, $constraints, $groups); } public function getMetadataFactory() { trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFor or Symfony\Component\Validator\Validator\ValidatorInterface::hasMetadataFor method instead.', E_USER_DEPRECATED); return $this->metadataFactory; } private static function testConstraints($constraints) { return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint); } private static function testGroups($groups) { return null === $groups || is_string($groups) || $groups instanceof GroupSequence || (is_array($groups) && (is_string(current($groups)) || current($groups) instanceof GroupSequence)); } } $obj = new RecursiveValidator();
based on 7jBGh
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function RecursiveValidator::__construct(), 0 passed in /in/P4R0p on line 107 and at least 3 expected in /in/P4R0p:26 Stack trace: #0 /in/P4R0p(107): RecursiveValidator->__construct() #1 {main} thrown in /in/P4R0p on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught TypeError: Argument 1 passed to RecursiveValidator::__construct() must be an instance of ExecutionContextFactoryInterface, none given, called in /in/P4R0p on line 107 and defined in /in/P4R0p:26 Stack trace: #0 /in/P4R0p(107): RecursiveValidator->__construct() #1 {main} thrown in /in/P4R0p on line 26
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Catchable fatal error: Argument 1 passed to RecursiveValidator::__construct() must be an instance of ExecutionContextFactoryInterface, none given, called in /in/P4R0p on line 107 and defined in /in/P4R0p on line 26
Process exited with code 255.