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($context); } class RecursiveValidator implements ValidatorInterfaceFirst, ValidatorInterfaceSecond { protected $contextFactory; protected $metadataFactory; protected $validatorFactory; protected $objectInitializers; public function __construct($contextFactory, $metadataFactory, $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($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.'); 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.'); 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 P4R0p
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function RecursiveValidator::__construct(), 0 passed in /in/5D4aI on line 113 and at least 3 expected in /in/5D4aI:26 Stack trace: #0 /in/5D4aI(113): RecursiveValidator->__construct() #1 {main} thrown in /in/5D4aI on line 26
Process exited with code 255.
Output for 5.3.9 - 7.0.20
Warning: Missing argument 1 for RecursiveValidator::__construct(), called in /in/5D4aI on line 113 and defined in /in/5D4aI on line 26 Warning: Missing argument 2 for RecursiveValidator::__construct(), called in /in/5D4aI on line 113 and defined in /in/5D4aI on line 26 Warning: Missing argument 3 for RecursiveValidator::__construct(), called in /in/5D4aI on line 113 and defined in /in/5D4aI on line 26 Notice: Undefined variable: contextFactory in /in/5D4aI on line 28 Notice: Undefined variable: metadataFactory in /in/5D4aI on line 29 Notice: Undefined variable: validatorFactory in /in/5D4aI on line 30
Output for 5.3.0 - 5.3.8
Fatal error: Can't inherit abstract function ValidatorInterfaceSecond::validate() (previously declared abstract in ValidatorInterfaceFirst) in /in/5D4aI on line 21
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Fatal error: Can't inherit abstract function ValidatorInterfaceSecond::validate() (previously declared abstract in ValidatorInterfaceFirst) in /in/5D4aI on line 20
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/5D4aI on line 26
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/5D4aI on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/5D4aI on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/5D4aI on line 2
Process exited with code 255.