protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath) { $this->context->setCurrentProperty($metadata->getPropertyName()); foreach ($metadata->findConstraints($group) as $constraint) { $this->walkConstraint($constraint, $value, $group, $propertyPath); } }
protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath, $propagatedGroup = null) { $this->context->setCurrentProperty($metadata->getPropertyName()); foreach ($metadata->findConstraints($group) as $constraint) { $this->walkConstraint($constraint, $value, $group, $propertyPath); } if ($metadata->isCascaded()) { $this->walkReference($value, $propagatedGroup ?: $group, $propertyPath); } }
/** * Constructor. * * @param string $class The class this property is defined on * @param string $name The name of this property */ public function __construct($class, $name) { if (!property_exists($class, $name)) { throw new ValidatorException(sprintf('Property %s does not exists in class %s', $name, $class)); } parent::__construct($class, $name, $name); }
/** * Constructor. * * @param string $class The class the getter is defined on * @param string $property The property which the getter returns */ public function __construct($class, $property) { $getMethod = 'get' . ucfirst($property); $isMethod = 'is' . ucfirst($property); if (method_exists($class, $getMethod)) { $method = $getMethod; } elseif (method_exists($class, $isMethod)) { $method = $isMethod; } else { throw new ValidatorException(sprintf('Neither method %s nor %s exists in class %s', $getMethod, $isMethod, $class)); } parent::__construct($class, $method, $property); }
/** * Adds a member metadata. * * @param MemberMetadata $metadata */ protected function addMemberMetadata(MemberMetadata $metadata) { $property = $metadata->getPropertyName(); $this->members[$property][] = $metadata; }
protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath, $propagatedGroup = null) { $metadata->accept($this->visitor, $value, $group, $propertyPath, $propagatedGroup); }
/** * Adds a member metadata * * @param MemberMetadata $metadata */ protected function addMemberMetadata(MemberMetadata $metadata) { $property = $metadata->getPropertyName(); if (!isset($this->members[$property])) { $this->members[$property] = array(); } $this->members[$property][] = $metadata; }
protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath, $propagatedGroup = null) { $currentClass = $metadata->getClassName(); $currentProperty = $metadata->getPropertyName(); foreach ($metadata->findConstraints($group) as $constraint) { $this->walkConstraint($constraint, $value, $group, $propertyPath, $currentClass, $currentProperty); } if ($metadata->isCascaded()) { $this->walkReference($value, $propagatedGroup ?: $group, $propertyPath, $metadata->isCollectionCascaded(), $metadata->isCollectionCascadedDeeply()); } }
/** * @param MemberMetadata $propertyMetadata * @param mixed $dataSource * @param string $dataSourceClass * @return null|array */ protected function findPropertyDataTypeInfo(MemberMetadata $propertyMetadata, $dataSource, $dataSourceClass) { if ($dataSource !== null) { $dataSource = $propertyMetadata->getReflectionMember($dataSourceClass)->getValue($dataSource); if (is_array($dataSource) || $dataSource instanceof \ArrayAccess) { return array(null, $dataSource); } if (is_object($dataSource)) { return array(get_class($dataSource), $dataSource); } return null; } // Since there is no datasource we need another way to determin the properties class foreach ($propertyMetadata->getConstraints() as $constraint) { if (!$constraint instanceof Type) { continue; } $type = strtolower($constraint->type); $type = $type == 'boolean' ? 'bool' : $constraint->type; $isFunction = 'is_' . $type; $ctypeFunction = 'ctype_' . $type; if (function_exists($isFunction) || function_exists($ctypeFunction)) { return null; } return array($constraint->type, null); } return null; }