*/
interface ValidatorBuilderInterface
{
/**
* Adds an object initializer to the validator.
*
* @param ObjectInitializerInterface $initializer The initializer.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addObjectInitializer(ObjectInitializerInterface $initializer);
/**
* Adds a list of object initializers to the validator.
*
* @param array $initializers The initializer.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addObjectInitializers(array $initializers);
/**
* Adds an XML constraint mapping file to the validator.
*
* @param string $path The path to the mapping file.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addXmlMapping($path);
/**
* Adds a list of XML constraint mapping files to the validator.
*
* @param array $paths The paths to the mapping files.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addXmlMappings(array $paths);
/**
* Adds a YAML constraint mapping file to the validator.
*
* @param string $path The path to the mapping file.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addYamlMapping($path);
/**
* Adds a list of YAML constraint mappings file to the validator.
*
* @param array $paths The paths to the mapping files.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addYamlMappings(array $paths);
/**
* Enables constraint mapping using the given static method.
*
* @param string $methodName The name of the method.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addMethodMapping($methodName);
/**
* Enables constraint mapping using the given static methods.
*
* @param array $methodNames The names of the methods.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function addMethodMappings(array $methodNames);
/**
* Enables annotation based constraint mapping.
*
* @param Reader $annotationReader The annotation reader to be used.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function enableAnnotationMapping(Reader $annotationReader = null);
/**
* Disables annotation based constraint mapping.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function disableAnnotationMapping();
/**
* Sets the class metadata factory used by the validator.
*
* @param MetadataFactoryInterface $metadataFactory The metadata factory.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function setMetadataFactory(MetadataFactoryInterface $metadataFactory);
/**
* Sets the cache for caching class metadata.
*
* @param CacheInterface $cache The cache instance.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function setMetadataCache(CacheInterface $cache);
/**
* Sets the constraint validator factory used by the validator.
*
* @param ConstraintValidatorFactoryInterface $validatorFactory The validator factory.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory);
/**
* Sets the translator used for translating violation messages.
*
* @param TranslatorInterface $translator The translator instance.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function setTranslator(TranslatorInterface $translator);
/**
* Sets the default translation domain of violation messages.
*
* The same message can have different translations in different domains.
* Pass the domain that is used for violation messages by default to this
* method.
*
* @param string $translationDomain The translation domain of the violation messages.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function setTranslationDomain($translationDomain);
/**
* Sets the property accessor for resolving property paths.
*
* @param PropertyAccessorInterface $propertyAccessor The property accessor.
*
* @return ValidatorBuilderInterface The builder object.
*/
public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor);
/**
* Builds and returns a new validator object.
*
* @return ValidatorInterface The built validator.
*/
public function getValidator();
}
PK ! oS S autoloader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
/**
* Stores the validator's state during validation.
*
* For example, let's validate the following object graph:
*
*
* (Person)---($firstName: string)
* \
* ($address: Address)---($street: string)
*
*
* We validate the Person instance, which becomes the "root" of the
* validation run (see {@link getRoot}). The state of the context after the
* first step will be like this:
*
*
* (Person)---($firstName: string)
* ^ \
* ($address: Address)---($street: string)
*
*
* The validator is stopped at the Person node, both the root and the
* value (see {@link getValue}) of the context point to the Person
* instance. The property path is empty at this point (see {@link getPropertyPath}).
* The metadata of the context is the metadata of the Person node
* (see {@link getMetadata}).
*
* After advancing to the property $firstName of the Person
* instance, the state of the context looks like this:
*
*
* (Person)---($firstName: string)
* \ ^
* ($address: Address)---($street: string)
*
*
* The validator is stopped at the property $firstName. The root still
* points to the Person instance, because this is where the validation
* started. The property path is now "firstName" and the current value is the
* value of that property.
*
* After advancing to the $address property and then to the
* $street property of the Address instance, the context state
* looks like this:
*
*
* (Person)---($firstName: string)
* \
* ($address: Address)---($street: string)
* ^
*
*
* The validator is stopped at the property $street. The root still
* points to the Person instance, but the property path is now
* "address.street" and the validated value is the value of that property.
*
* Apart from the root, the property path and the currently validated value,
* the execution context also knows the metadata of the current node (see
* {@link getMetadata}) which for example returns a {@link Mapping\PropertyMetadata}
* or a {@link Mapping\ClassMetadata} object. he context also contains the
* validation group that is currently being validated (see {@link getGroup}) and
* the violations that happened up until now (see {@link getViolations}).
*
* Apart from reading the execution context, you can also use
* {@link addViolation} or {@link addViolationAt} to add new violations and
* {@link validate} or {@link validateValue} to validate values that the
* validator otherwise would not reach.
*
* @author Bernhard Schussek
*
* @api
*/
interface ExecutionContextInterface
{
/**
* Adds a violation at the current node of the validation graph.
*
* @param string $message The error message.
* @param array $params The parameters substituted in the error message.
* @param mixed $invalidValue The invalid, validated value.
* @param integer|null $pluralization The number to use to pluralize of the message.
* @param integer|null $code The violation code.
*
* @api
*/
public function addViolation($message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null);
/**
* Adds a violation at the validation graph node with the given property
* path relative to the current property path.
*
* @param string $subPath The relative property path for the violation.
* @param string $message The error message.
* @param array $params The parameters substituted in the error message.
* @param mixed $invalidValue The invalid, validated value.
* @param integer|null $pluralization The number to use to pluralize of the message.
* @param integer|null $code The violation code.
*
* @api
*/
public function addViolationAt($subPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null);
/**
* Validates the given value within the scope of the current validation.
*
* The value may be any value recognized by the used metadata factory
* (see {@link MetadataFactoryInterface::getMetadata}), or an array or a
* traversable object of such values.
*
* Usually you validate a value that is not the current node of the
* execution context. For this case, you can pass the {@link $subPath}
* argument which is appended to the current property path when a violation
* is created. For example, take the following object graph:
*
*
* (Person)---($address: Address)---($phoneNumber: PhoneNumber)
* ^
*
*
* When the execution context stops at the Person instance, the
* property path is "address". When you validate the PhoneNumber
* instance now, pass "phoneNumber" as sub path to correct the property path
* to "address.phoneNumber":
*
*
* $context->validate($address->phoneNumber, 'phoneNumber');
*
*
* Any violations generated during the validation will be added to the
* violation list that you can access with {@link getViolations}.
*
* @param mixed $value The value to validate.
* @param string $subPath The path to append to the context's property path.
* @param null|string|string[] $groups The groups to validate in. If you don't pass any
* groups here, the current group of the context
* will be used.
* @param Boolean $traverse Whether to traverse the value if it is an array
* or an instance of \Traversable.
* @param Boolean $deep Whether to traverse the value recursively if
* it is a collection of collections.
*/
public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false);
/**
* Validates a value against a constraint.
*
* Use the parameter $subPath to adapt the property path for the
* validated value. For example, take the following object graph:
*
*
* (Person)---($address: Address)---($street: string)
* ^
*
*
* When the validator validates the Address instance, the
* property path stored in the execution context is "address". When you
* manually validate the property $street now, pass the sub path
* "street" to adapt the full property path to "address.street":
*
*
* $context->validate($address->street, new NotNull(), 'street');
*
*
* @param mixed $value The value to validate.
* @param Constraint|Constraint[] $constraints The constraint(s) to validate against.
* @param string $subPath The path to append to the context's property path.
* @param null|string|string[] $groups The groups to validate in. If you don't pass any
* groups here, the current group of the context
* will be used.
*/
public function validateValue($value, $constraints, $subPath = '', $groups = null);
/**
* Returns the violations generated by the validator so far.
*
* @return ConstraintViolationListInterface The constraint violation list.
*
* @api
*/
public function getViolations();
/**
* Returns the value at which validation was started in the object graph.
*
* The validator, when given an object, traverses the properties and
* related objects and their properties. The root of the validation is the
* object from which the traversal started.
*
* The current value is returned by {@link getValue}.
*
* @return mixed The root value of the validation.
*/
public function getRoot();
/**
* Returns the value that the validator is currently validating.
*
* If you want to retrieve the object that was originally passed to the
* validator, use {@link getRoot}.
*
* @return mixed The currently validated value.
*/
public function getValue();
/**
* Returns the metadata for the currently validated value.
*
* With the core implementation, this method returns a
* {@link Mapping\ClassMetadata} instance if the current value is an object,
* a {@link Mapping\PropertyMetadata} instance if the current value is
* the value of a property and a {@link Mapping\GetterMetadata} instance if
* the validated value is the result of a getter method.
*
* If the validated value is neither of these, for example if the validator
* has been called with a plain value and constraint, this method returns
* null.
*
* @return MetadataInterface|null The metadata of the currently validated
* value.
*/
public function getMetadata();
/**
* Returns the used metadata factory.
*
* @return MetadataFactoryInterface The metadata factory.
*/
public function getMetadataFactory();
/**
* Returns the validation group that is currently being validated.
*
* @return string The current validation group.
*/
public function getGroup();
/**
* Returns the class name of the current node.
*
* If the metadata of the current node does not implement
* {@link ClassBasedInterface} or if no metadata is available for the
* current node, this method returns null.
*
* @return string|null The class name or null, if no class name could be found.
*/
public function getClassName();
/**
* Returns the property name of the current node.
*
* If the metadata of the current node does not implement
* {@link PropertyMetadataInterface} or if no metadata is available for the
* current node, this method returns null.
*
* @return string|null The property name or null, if no property name could be found.
*/
public function getPropertyName();
/**
* Returns the property path to the value that the validator is currently
* validating.
*
* For example, take the following object graph:
*
*
* (Person)---($address: Address)---($street: string)
*
*
* When the Person instance is passed to the validator, the
* property path is initially empty. When the $address property
* of that person is validated, the property path is "address". When
* the $street property of the related Address instance
* is validated, the property path is "address.street".
*
* Properties of objects are prefixed with a dot in the property path.
* Indices of arrays or objects implementing the {@link \ArrayAccess}
* interface are enclosed in brackets. For example, if the property in
* the previous example is $addresses and contains an array
* of Address instance, the property path generated for the
* $street property of one of these addresses is for example
* "addresses[0].street".
*
* @param string $subPath Optional. The suffix appended to the current
* property path.
*
* @return string The current property path. The result may be an empty
* string if the validator is currently validating the
* root value of the validation graph.
*/
public function getPropertyPath($subPath = '');
}
PK ! }` PropertyMetadataInterface.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
/**
* A container for validation metadata of a property.
*
* What exactly you define as "property" is up to you. The validator expects
* implementations of {@link MetadataInterface} that contain constraints and
* optionally a list of named properties that also have constraints (and may
* have further sub properties). Such properties are mapped by implementations
* of this interface.
*
* @author Bernhard Schussek
*
* @see MetadataInterface
*/
interface PropertyMetadataInterface extends MetadataInterface
{
/**
* Returns the name of the property.
*
* @return string The property name.
*/
public function getPropertyName();
/**
* Extracts the value of the property from the given container.
*
* @param mixed $containingValue The container to extract the property value from.
*
* @return mixed The value of the property.
*/
public function getPropertyValue($containingValue);
}
PK ! /! /! ExecutionContext.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
use Symfony\Component\Translation\TranslatorInterface;
/**
* Default implementation of {@link ExecutionContextInterface}.
*
* This class is immutable by design.
*
* @author Fabien Potencier
* @author Bernhard Schussek
*/
class ExecutionContext implements ExecutionContextInterface
{
/**
* @var GlobalExecutionContextInterface
*/
private $globalContext;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var null|string
*/
private $translationDomain;
/**
* @var MetadataInterface
*/
private $metadata;
/**
* @var mixed
*/
private $value;
/**
* @var string
*/
private $group;
/**
* @var string
*/
private $propertyPath;
/**
* Creates a new execution context.
*
* @param GlobalExecutionContextInterface $globalContext The global context storing node-independent state.
* @param TranslatorInterface $translator The translator for translating violation messages.
* @param null|string $translationDomain The domain of the validation messages.
* @param MetadataInterface $metadata The metadata of the validated node.
* @param mixed $value The value of the validated node.
* @param string $group The current validation group.
* @param string $propertyPath The property path to the current node.
*/
public function __construct(GlobalExecutionContextInterface $globalContext, TranslatorInterface $translator, $translationDomain = null, MetadataInterface $metadata = null, $value = null, $group = null, $propertyPath = '')
{
if (null === $group) {
$group = Constraint::DEFAULT_GROUP;
}
$this->globalContext = $globalContext;
$this->translator = $translator;
$this->translationDomain = $translationDomain;
$this->metadata = $metadata;
$this->value = $value;
$this->propertyPath = $propertyPath;
$this->group = $group;
}
/**
* {@inheritdoc}
*/
public function addViolation($message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null)
{
if (null === $pluralization) {
$translatedMessage = $this->translator->trans($message, $params, $this->translationDomain);
} else {
try {
$translatedMessage = $this->translator->transChoice($message, $pluralization, $params, $this->translationDomain);
} catch (\InvalidArgumentException $e) {
$translatedMessage = $this->translator->trans($message, $params, $this->translationDomain);
}
}
$this->globalContext->getViolations()->add(new ConstraintViolation(
$translatedMessage,
$message,
$params,
$this->globalContext->getRoot(),
$this->propertyPath,
// check using func_num_args() to allow passing null values
func_num_args() >= 3 ? $invalidValue : $this->value,
$pluralization,
$code
));
}
/**
* {@inheritdoc}
*/
public function addViolationAt($subPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null)
{
$this->globalContext->getViolations()->add(new ConstraintViolation(
null === $pluralization
? $this->translator->trans($message, $params, $this->translationDomain)
: $this->translator->transChoice($message, $pluralization, $params, $this->translationDomain),
$message,
$params,
$this->globalContext->getRoot(),
$this->getPropertyPath($subPath),
// check using func_num_args() to allow passing null values
func_num_args() >= 4 ? $invalidValue : $this->value,
$pluralization,
$code
));
}
/**
* {@inheritdoc}
*/
public function getViolations()
{
return $this->globalContext->getViolations();
}
/**
* {@inheritdoc}
*/
public function getRoot()
{
return $this->globalContext->getRoot();
}
/**
* {@inheritdoc}
*/
public function getPropertyPath($subPath = '')
{
if ('' != $subPath && '' !== $this->propertyPath && '[' !== $subPath[0]) {
return $this->propertyPath.'.'.$subPath;
}
return $this->propertyPath.$subPath;
}
/**
* {@inheritdoc}
*/
public function getClassName()
{
if ($this->metadata instanceof ClassBasedInterface) {
return $this->metadata->getClassName();
}
return null;
}
/**
* {@inheritdoc}
*/
public function getPropertyName()
{
if ($this->metadata instanceof PropertyMetadataInterface) {
return $this->metadata->getPropertyName();
}
return null;
}
/**
* {@inheritdoc}
*/
public function getValue()
{
return $this->value;
}
/**
* {@inheritdoc}
*/
public function getGroup()
{
return $this->group;
}
/**
* {@inheritdoc}
*/
public function getMetadata()
{
return $this->metadata;
}
/**
* {@inheritdoc}
*/
public function getMetadataFor($value)
{
return $this->globalContext->getMetadataFactory()->getMetadataFor($value);
}
/**
* {@inheritdoc}
*/
public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false)
{
$propertyPath = $this->getPropertyPath($subPath);
foreach ($this->resolveGroups($groups) as $group) {
$this->globalContext->getVisitor()->validate($value, $group, $propertyPath, $traverse, $deep);
}
}
/**
* {@inheritdoc}
*/
public function validateValue($value, $constraints, $subPath = '', $groups = null)
{
$constraints = is_array($constraints) ? $constraints : array($constraints);
if (null === $groups && '' === $subPath) {
$context = clone $this;
$context->value = $value;
$context->executeConstraintValidators($value, $constraints);
return;
}
$propertyPath = $this->getPropertyPath($subPath);
foreach ($this->resolveGroups($groups) as $group) {
$context = clone $this;
$context->value = $value;
$context->group = $group;
$context->propertyPath = $propertyPath;
$context->executeConstraintValidators($value, $constraints);
}
}
/**
* {@inheritdoc}
*/
public function getMetadataFactory()
{
return $this->globalContext->getMetadataFactory();
}
/**
* Executes the validators of the given constraints for the given value.
*
* @param mixed $value The value to validate.
* @param Constraint[] $constraints The constraints to match against.
*/
private function executeConstraintValidators($value, array $constraints)
{
foreach ($constraints as $constraint) {
$validator = $this->globalContext->getValidatorFactory()->getInstance($constraint);
$validator->initialize($this);
$validator->validate($value, $constraint);
}
}
/**
* Returns an array of group names.
*
* @param null|string|string[] $groups The groups to resolve. If a single string is
* passed, it is converted to an array. If null
* is passed, an array containing the current
* group of the context is returned.
*
* @return array An array of validation groups.
*/
private function resolveGroups($groups)
{
return $groups ? (array) $groups : (array) $this->group;
}
}
PK ! +s ConstraintValidatorFactory.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Validator\Constraints\ExpressionValidator;
/**
* Default implementation of the ConstraintValidatorFactoryInterface.
*
* This enforces the convention that the validatedBy() method on any
* Constraint will return the class name of the ConstraintValidator that
* should validate the Constraint.
*
* @author Bernhard Schussek
*/
class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
{
protected $validators = array();
/**
* @var PropertyAccessorInterface
*/
private $propertyAccessor;
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
{
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
}
/**
* {@inheritDoc}
*/
public function getInstance(Constraint $constraint)
{
$className = $constraint->validatedBy();
// The second condition is a hack that is needed when CollectionValidator
// calls itself recursively (Collection constraints can be nested).
// Since the context of the validator is overwritten when initialize()
// is called for the nested constraint, the outer validator is
// acting on the wrong context when the nested validation terminates.
//
// A better solution - which should be approached in Symfony 3.0 - is to
// remove the initialize() method and pass the context as last argument
// to validate() instead.
if (!isset($this->validators[$className]) || 'Symfony\Component\Validator\Constraints\CollectionValidator' === $className) {
$this->validators[$className] = 'validator.expression' === $className
? new ExpressionValidator($this->propertyAccessor)
: new $className();
}
return $this->validators[$className];
}
}
PK ! SqK K MetadataInterface.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
/**
* A container for validation metadata.
*
* The container contains constraints that may belong to different validation
* groups. Constraints for a specific group can be fetched by calling
* {@link findConstraints}.
*
* Implement this interface to add validation metadata to your own metadata
* layer. Each metadata may have named properties. Each property can be
* represented by one or more {@link PropertyMetadataInterface} instances that
* are returned by {@link getPropertyMetadata}. Since
* PropertyMetadataInterface inherits from MetadataInterface,
* each property may be divided into further properties.
*
* The {@link accept} method of each metadata implements the Visitor pattern.
* The method should forward the call to the visitor's
* {@link ValidationVisitorInterface::visit} method and additionally call
* accept() on all structurally related metadata instances.
*
* For example, to store constraints for PHP classes and their properties,
* create a class ClassMetadata (implementing MetadataInterface)
* and a class PropertyMetadata (implementing PropertyMetadataInterface).
* ClassMetadata::getPropertyMetadata($property) returns all
* PropertyMetadata instances for a property of that class. Its
* accept()-method simply forwards to ValidationVisitorInterface::visit()
* and calls accept() on all contained PropertyMetadata
* instances, which themselves call ValidationVisitorInterface::visit()
* again.
*
* @author Bernhard Schussek
*/
interface MetadataInterface
{
/**
* Implementation of the Visitor design pattern.
*
* Calls {@link ValidationVisitorInterface::visit} and then forwards the
* accept()-call to all property metadata instances.
*
* @param ValidationVisitorInterface $visitor The visitor implementing the validation logic.
* @param mixed $value The value to validate.
* @param string|string[] $group The validation group to validate in.
* @param string $propertyPath The current property path in the validation graph.
*/
public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath);
/**
* Returns all constraints for a given validation group.
*
* @param string $group The validation group.
*
* @return Constraint[] A list of constraint instances.
*/
public function findConstraints($group);
}
PK ! R' ConstraintViolationInterface.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
/**
* A violation of a constraint that happened during validation.
*
* For each constraint that fails during validation one or more violations are
* created. The violations store the violation message, the path to the failing
* element in the validation graph and the root element that was originally
* passed to the validator. For example, take the following graph:
*
*
* (Person)---(firstName: string)
* \
* (address: Address)---(street: string)
*
*
* If the Person object is validated and validation fails for the
* "firstName" property, the generated violation has the Person
* instance as root and the property path "firstName". If validation fails
* for the "street" property of the related Address instance, the root
* element is still the person, but the property path is "address.street".
*
* @author Bernhard Schussek
*
* @api
*/
interface ConstraintViolationInterface
{
/**
* Returns the violation message.
*
* @return string The violation message.
*
* @api
*/
public function getMessage();
/**
* Returns the raw violation message.
*
* The raw violation message contains placeholders for the parameters
* returned by {@link getMessageParameters}. Typically you'll pass the
* message template and parameters to a translation engine.
*
* @return string The raw violation message.
*
* @api
*/
public function getMessageTemplate();
/**
* Returns the parameters to be inserted into the raw violation message.
*
* @return array A possibly empty list of parameters indexed by the names
* that appear in the message template.
*
* @see getMessageTemplate
*
* @api
*/
public function getMessageParameters();
/**
* Returns a number for pluralizing the violation message.
*
* For example, the message template could have different translation based
* on a parameter "choices":
*
*
* - Please select exactly one entry. (choices=1)
* - Please select two entries. (choices=2)
*
*
* This method returns the value of the parameter for choosing the right
* pluralization form (in this case "choices").
*
* @return integer|null The number to use to pluralize of the message.
*/
public function getMessagePluralization();
/**
* Returns the root element of the validation.
*
* @return mixed The value that was passed originally to the validator when
* the validation was started. Because the validator traverses
* the object graph, the value at which the violation occurs
* is not necessarily the value that was originally validated.
*
* @api
*/
public function getRoot();
/**
* Returns the property path from the root element to the violation.
*
* @return string The property path indicates how the validator reached
* the invalid value from the root element. If the root
* element is a Person instance with a property
* "address" that contains an Address instance
* with an invalid property "street", the generated property
* path is "address.street". Property access is denoted by
* dots, while array access is denoted by square brackets,
* for example "addresses[1].street".
*
* @api
*/
public function getPropertyPath();
/**
* Returns the value that caused the violation.
*
* @return mixed The invalid value that caused the validated constraint to
* fail.
*
* @api
*/
public function getInvalidValue();
/**
* Returns a machine-digestible error code for the violation.
*
* @return mixed The error code.
*/
public function getCode();
}
PK ! ƭW Constraint.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
use Symfony\Component\Validator\Exception\InvalidOptionsException;
use Symfony\Component\Validator\Exception\MissingOptionsException;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
/**
* Contains the properties of a constraint definition.
*
* A constraint can be defined on a class, an option or a getter method.
* The Constraint class encapsulates all the configuration required for
* validating this class, option or getter result successfully.
*
* Constraint instances are immutable and serializable.
*
* @author Bernhard Schussek
*
* @api
*/
abstract class Constraint
{
/**
* The name of the group given to all constraints with no explicit group
* @var string
*/
const DEFAULT_GROUP = 'Default';
/**
* Marks a constraint that can be put onto classes
* @var string
*/
const CLASS_CONSTRAINT = 'class';
/**
* Marks a constraint that can be put onto properties
* @var string
*/
const PROPERTY_CONSTRAINT = 'property';
/**
* @var array
*/
public $groups = array(self::DEFAULT_GROUP);
/**
* Initializes the constraint with options.
*
* You should pass an associative array. The keys should be the names of
* existing properties in this class. The values should be the value for these
* properties.
*
* Alternatively you can override the method getDefaultOption() to return the
* name of an existing property. If no associative array is passed, this
* property is set instead.
*
* You can force that certain options are set by overriding
* getRequiredOptions() to return the names of these options. If any
* option is not set here, an exception is thrown.
*
* @param mixed $options The options (as associative array)
* or the value for the default
* option (any other type)
*
* @throws InvalidOptionsException When you pass the names of non-existing
* options
* @throws MissingOptionsException When you don't pass any of the options
* returned by getRequiredOptions()
* @throws ConstraintDefinitionException When you don't pass an associative
* array, but getDefaultOption() returns
* null
*
* @api
*/
public function __construct($options = null)
{
$invalidOptions = array();
$missingOptions = array_flip((array) $this->getRequiredOptions());
if (is_array($options) && count($options) >= 1 && isset($options['value']) && !property_exists($this, 'value')) {
$options[$this->getDefaultOption()] = $options['value'];
unset($options['value']);
}
if (is_array($options) && count($options) > 0 && is_string(key($options))) {
foreach ($options as $option => $value) {
if (property_exists($this, $option)) {
$this->$option = $value;
unset($missingOptions[$option]);
} else {
$invalidOptions[] = $option;
}
}
} elseif (null !== $options && ! (is_array($options) && count($options) === 0)) {
$option = $this->getDefaultOption();
if (null === $option) {
throw new ConstraintDefinitionException(
sprintf('No default option is configured for constraint %s', get_class($this))
);
}
if (property_exists($this, $option)) {
$this->$option = $options;
unset($missingOptions[$option]);
} else {
$invalidOptions[] = $option;
}
}
if (count($invalidOptions) > 0) {
throw new InvalidOptionsException(
sprintf('The options "%s" do not exist in constraint %s', implode('", "', $invalidOptions), get_class($this)),
$invalidOptions
);
}
if (count($missingOptions) > 0) {
throw new MissingOptionsException(
sprintf('The options "%s" must be set for constraint %s', implode('", "', array_keys($missingOptions)), get_class($this)),
array_keys($missingOptions)
);
}
$this->groups = (array) $this->groups;
}
/**
* Unsupported operation.
*/
public function __set($option, $value)
{
throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, get_class($this)), array($option));
}
/**
* Adds the given group if this constraint is in the Default group
*
* @param string $group
*
* @api
*/
public function addImplicitGroupName($group)
{
if (in_array(Constraint::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) {
$this->groups[] = $group;
}
}
/**
* Returns the name of the default option
*
* Override this method to define a default option.
*
* @return string
* @see __construct()
*
* @api
*/
public function getDefaultOption()
{
return null;
}
/**
* Returns the name of the required options
*
* Override this method if you want to define required options.
*
* @return array
* @see __construct()
*
* @api
*/
public function getRequiredOptions()
{
return array();
}
/**
* Returns the name of the class that validates this constraint
*
* By default, this is the fully qualified name of the constraint class
* suffixed with "Validator". You can override this method to change that
* behaviour.
*
* @return string
*
* @api
*/
public function validatedBy()
{
return get_class($this).'Validator';
}
/**
* Returns whether the constraint can be put onto classes, properties or
* both
*
* This method should return one or more of the constants
* Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT.
*
* @return string|array One or more constant values
*
* @api
*/
public function getTargets()
{
return self::PROPERTY_CONSTRAINT;
}
}
PK ! | Mapping/GetterMetadata.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Exception\ValidatorException;
class GetterMetadata extends MemberMetadata
{
/**
* Constructor.
*
* @param string $class The class the getter is defined on
* @param string $property The property which the getter returns
*
* @throws ValidatorException
*/
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);
}
/**
* {@inheritDoc}
*/
public function getPropertyValue($object)
{
return $this->newReflectionMember($object)->invoke($object);
}
/**
* {@inheritDoc}
*/
protected function newReflectionMember($objectOrClassName)
{
return new \ReflectionMethod($objectOrClassName, $this->getName());
}
}
PK ! r
Mapping/PropertyMetadata.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Exception\ValidatorException;
class PropertyMetadata extends MemberMetadata
{
/**
* Constructor.
*
* @param string $class The class this property is defined on
* @param string $name The name of this property
*
* @throws ValidatorException
*/
public function __construct($class, $name)
{
if (!property_exists($class, $name)) {
throw new ValidatorException(sprintf('Property %s does not exist in class %s', $name, $class));
}
parent::__construct($class, $name, $name);
}
/**
* {@inheritDoc}
*/
public function getPropertyValue($object)
{
return $this->getReflectionMember($object)->getValue($object);
}
/**
* {@inheritDoc}
*/
protected function newReflectionMember($objectOrClassName)
{
$class = new \ReflectionClass($objectOrClassName);
while (!$class->hasProperty($this->getName())) {
$class = $class->getParentClass();
}
$member = new \ReflectionProperty($class->getName(), $this->getName());
$member->setAccessible(true);
return $member;
}
}
PK ! t./ ./ Mapping/ClassMetadata.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\ValidationVisitorInterface;
use Symfony\Component\Validator\PropertyMetadataContainerInterface;
use Symfony\Component\Validator\ClassBasedInterface;
use Symfony\Component\Validator\MetadataInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\GroupDefinitionException;
/**
* Represents all the configured constraints on a given class.
*
* @author Bernhard Schussek
* @author Fabien Potencier
*/
class ClassMetadata extends ElementMetadata implements MetadataInterface, ClassBasedInterface, PropertyMetadataContainerInterface
{
/**
* @var string
*/
public $name;
/**
* @var string
*/
public $defaultGroup;
/**
* @var MemberMetadata[]
*/
public $members = array();
/**
* @var PropertyMetadata[]
*/
public $properties = array();
/**
* @var GetterMetadata[]
*/
public $getters = array();
/**
* @var array
*/
public $groupSequence = array();
/**
* @var Boolean
*/
public $groupSequenceProvider = false;
/**
* @var \ReflectionClass
*/
private $reflClass;
/**
* Constructs a metadata for the given class
*
* @param string $class
*/
public function __construct($class)
{
$this->name = $class;
// class name without namespace
if (false !== $nsSep = strrpos($class, '\\')) {
$this->defaultGroup = substr($class, $nsSep + 1);
} else {
$this->defaultGroup = $class;
}
}
public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath, $propagatedGroup = null)
{
if (null === $propagatedGroup && Constraint::DEFAULT_GROUP === $group
&& ($this->hasGroupSequence() || $this->isGroupSequenceProvider())) {
if ($this->hasGroupSequence()) {
$groups = $this->getGroupSequence();
} else {
$groups = $value->getGroupSequence();
}
foreach ($groups as $group) {
$this->accept($visitor, $value, $group, $propertyPath, Constraint::DEFAULT_GROUP);
if (count($visitor->getViolations()) > 0) {
break;
}
}
return;
}
$visitor->visit($this, $value, $group, $propertyPath);
if (null !== $value) {
$pathPrefix = empty($propertyPath) ? '' : $propertyPath.'.';
foreach ($this->getConstrainedProperties() as $property) {
foreach ($this->getMemberMetadatas($property) as $member) {
$member->accept($visitor, $member->getPropertyValue($value), $group, $pathPrefix.$property, $propagatedGroup);
}
}
}
}
/**
* Returns the properties to be serialized
*
* @return array
*/
public function __sleep()
{
return array_merge(parent::__sleep(), array(
'getters',
'groupSequence',
'groupSequenceProvider',
'members',
'name',
'properties',
'defaultGroup'
));
}
/**
* Returns the fully qualified name of the class
*
* @return string The fully qualified class name
*/
public function getClassName()
{
return $this->name;
}
/**
* Returns the name of the default group for this class
*
* For each class, the group "Default" is an alias for the group
* "", where is the non-namespaced name of the
* class. All constraints implicitly or explicitly assigned to group
* "Default" belong to both of these groups, unless the class defines
* a group sequence.
*
* If a class defines a group sequence, validating the class in "Default"
* will validate the group sequence. The constraints assigned to "Default"
* can still be validated by validating the class in "".
*
* @return string The name of the default group
*/
public function getDefaultGroup()
{
return $this->defaultGroup;
}
/**
* {@inheritDoc}
*/
public function addConstraint(Constraint $constraint)
{
if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {
throw new ConstraintDefinitionException(sprintf(
'The constraint %s cannot be put on classes',
get_class($constraint)
));
}
$constraint->addImplicitGroupName($this->getDefaultGroup());
parent::addConstraint($constraint);
}
/**
* Adds a constraint to the given property.
*
* @param string $property The name of the property
* @param Constraint $constraint The constraint
*
* @return ClassMetadata This object
*/
public function addPropertyConstraint($property, Constraint $constraint)
{
if (!isset($this->properties[$property])) {
$this->properties[$property] = new PropertyMetadata($this->getClassName(), $property);
$this->addMemberMetadata($this->properties[$property]);
}
$constraint->addImplicitGroupName($this->getDefaultGroup());
$this->properties[$property]->addConstraint($constraint);
return $this;
}
/**
* Adds a constraint to the getter of the given property.
*
* The name of the getter is assumed to be the name of the property with an
* uppercased first letter and either the prefix "get" or "is".
*
* @param string $property The name of the property
* @param Constraint $constraint The constraint
*
* @return ClassMetadata This object
*/
public function addGetterConstraint($property, Constraint $constraint)
{
if (!isset($this->getters[$property])) {
$this->getters[$property] = new GetterMetadata($this->getClassName(), $property);
$this->addMemberMetadata($this->getters[$property]);
}
$constraint->addImplicitGroupName($this->getDefaultGroup());
$this->getters[$property]->addConstraint($constraint);
return $this;
}
/**
* Merges the constraints of the given metadata into this object.
*
* @param ClassMetadata $source The source metadata
*/
public function mergeConstraints(ClassMetadata $source)
{
foreach ($source->getConstraints() as $constraint) {
$this->addConstraint(clone $constraint);
}
foreach ($source->getConstrainedProperties() as $property) {
foreach ($source->getMemberMetadatas($property) as $member) {
$member = clone $member;
foreach ($member->getConstraints() as $constraint) {
$constraint->addImplicitGroupName($this->getDefaultGroup());
}
$this->addMemberMetadata($member);
if (!$member->isPrivate($this->name)) {
$property = $member->getPropertyName();
if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
$this->properties[$property] = $member;
} elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
$this->getters[$property] = $member;
}
}
}
}
}
/**
* Adds a member metadata.
*
* @param MemberMetadata $metadata
*/
protected function addMemberMetadata(MemberMetadata $metadata)
{
$property = $metadata->getPropertyName();
$this->members[$property][] = $metadata;
}
/**
* Returns true if metadatas of members is present for the given property.
*
* @param string $property The name of the property
*
* @return Boolean
*/
public function hasMemberMetadatas($property)
{
return array_key_exists($property, $this->members);
}
/**
* Returns all metadatas of members describing the given property.
*
* @param string $property The name of the property
*
* @return MemberMetadata[] An array of MemberMetadata
*/
public function getMemberMetadatas($property)
{
return $this->members[$property];
}
/**
* {@inheritdoc}
*/
public function hasPropertyMetadata($property)
{
return array_key_exists($property, $this->members);
}
/**
* {@inheritdoc}
*/
public function getPropertyMetadata($property)
{
return $this->members[$property];
}
/**
* Returns all properties for which constraints are defined.
*
* @return array An array of property names
*/
public function getConstrainedProperties()
{
return array_keys($this->members);
}
/**
* Sets the default group sequence for this class.
*
* @param array $groups An array of group names
*
* @return ClassMetadata
*
* @throws GroupDefinitionException
*/
public function setGroupSequence(array $groups)
{
if ($this->isGroupSequenceProvider()) {
throw new GroupDefinitionException('Defining a static group sequence is not allowed with a group sequence provider');
}
if (in_array(Constraint::DEFAULT_GROUP, $groups, true)) {
throw new GroupDefinitionException(sprintf('The group "%s" is not allowed in group sequences', Constraint::DEFAULT_GROUP));
}
if (!in_array($this->getDefaultGroup(), $groups, true)) {
throw new GroupDefinitionException(sprintf('The group "%s" is missing in the group sequence', $this->getDefaultGroup()));
}
$this->groupSequence = $groups;
return $this;
}
/**
* Returns whether this class has an overridden default group sequence.
*
* @return Boolean
*/
public function hasGroupSequence()
{
return count($this->groupSequence) > 0;
}
/**
* Returns the default group sequence for this class.
*
* @return array An array of group names
*/
public function getGroupSequence()
{
return $this->groupSequence;
}
/**
* Returns a ReflectionClass instance for this class.
*
* @return \ReflectionClass
*/
public function getReflectionClass()
{
if (!$this->reflClass) {
$this->reflClass = new \ReflectionClass($this->getClassName());
}
return $this->reflClass;
}
/**
* Sets whether a group sequence provider should be used.
*
* @param Boolean $active
*
* @throws GroupDefinitionException
*/
public function setGroupSequenceProvider($active)
{
if ($this->hasGroupSequence()) {
throw new GroupDefinitionException('Defining a group sequence provider is not allowed with a static group sequence');
}
if (!$this->getReflectionClass()->implementsInterface('Symfony\Component\Validator\GroupSequenceProviderInterface')) {
throw new GroupDefinitionException(sprintf('Class "%s" must implement GroupSequenceProviderInterface', $this->name));
}
$this->groupSequenceProvider = $active;
}
/**
* Returns whether the class is a group sequence provider.
*
* @return Boolean
*/
public function isGroupSequenceProvider()
{
return $this->groupSequenceProvider;
}
}
PK ! !" " Mapping/ElementMetadata.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Constraint;
abstract class ElementMetadata
{
/**
* @var Constraint[]
*/
public $constraints = array();
/**
* @var array
*/
public $constraintsByGroup = array();
/**
* Returns the names of the properties that should be serialized.
*
* @return array
*/
public function __sleep()
{
return array(
'constraints',
'constraintsByGroup',
);
}
/**
* Clones this object.
*/
public function __clone()
{
$constraints = $this->constraints;
$this->constraints = array();
$this->constraintsByGroup = array();
foreach ($constraints as $constraint) {
$this->addConstraint(clone $constraint);
}
}
/**
* Adds a constraint to this element.
*
* @param Constraint $constraint
*
* @return ElementMetadata
*/
public function addConstraint(Constraint $constraint)
{
$this->constraints[] = $constraint;
foreach ($constraint->groups as $group) {
$this->constraintsByGroup[$group][] = $constraint;
}
return $this;
}
/**
* Returns all constraints of this element.
*
* @return Constraint[] An array of Constraint instances
*/
public function getConstraints()
{
return $this->constraints;
}
/**
* Returns whether this element has any constraints.
*
* @return Boolean
*/
public function hasConstraints()
{
return count($this->constraints) > 0;
}
/**
* Returns the constraints of the given group and global ones (* group).
*
* @param string $group The group name
*
* @return array An array with all Constraint instances belonging to the group
*/
public function findConstraints($group)
{
return isset($this->constraintsByGroup[$group])
? $this->constraintsByGroup[$group]
: array();
}
}
PK ! /;a a Mapping/MemberMetadata.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\ValidationVisitorInterface;
use Symfony\Component\Validator\ClassBasedInterface;
use Symfony\Component\Validator\PropertyMetadataInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
abstract class MemberMetadata extends ElementMetadata implements PropertyMetadataInterface, ClassBasedInterface
{
public $class;
public $name;
public $property;
public $cascaded = false;
public $collectionCascaded = false;
public $collectionCascadedDeeply = false;
private $reflMember = array();
/**
* Constructor.
*
* @param string $class The name of the class this member is defined on
* @param string $name The name of the member
* @param string $property The property the member belongs to
*/
public function __construct($class, $name, $property)
{
$this->class = $class;
$this->name = $name;
$this->property = $property;
}
public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath, $propagatedGroup = null)
{
$visitor->visit($this, $value, $group, $propertyPath);
if ($this->isCascaded()) {
$visitor->validate($value, $propagatedGroup ?: $group, $propertyPath, $this->isCollectionCascaded(), $this->isCollectionCascadedDeeply());
}
}
/**
* {@inheritDoc}
*/
public function addConstraint(Constraint $constraint)
{
if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) {
throw new ConstraintDefinitionException(sprintf(
'The constraint %s cannot be put on properties or getters',
get_class($constraint)
));
}
if ($constraint instanceof Valid) {
$this->cascaded = true;
/* @var Valid $constraint */
$this->collectionCascaded = $constraint->traverse;
$this->collectionCascadedDeeply = $constraint->deep;
} else {
parent::addConstraint($constraint);
}
return $this;
}
/**
* Returns the names of the properties that should be serialized
*
* @return array
*/
public function __sleep()
{
return array_merge(parent::__sleep(), array(
'class',
'name',
'property',
'cascaded',
'collectionCascaded',
'collectionCascadedDeeply',
));
}
/**
* Returns the name of the member
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Returns the class this member is defined on
*
* @return string
*/
public function getClassName()
{
return $this->class;
}
/**
* Returns the name of the property this member belongs to
*
* @return string The property name
*/
public function getPropertyName()
{
return $this->property;
}
/**
* Returns whether this member is public
*
* @param object|string $objectOrClassName The object or the class name
*
* @return Boolean
*/
public function isPublic($objectOrClassName)
{
return $this->getReflectionMember($objectOrClassName)->isPublic();
}
/**
* Returns whether this member is protected
*
* @param object|string $objectOrClassName The object or the class name
*
* @return Boolean
*/
public function isProtected($objectOrClassName)
{
return $this->getReflectionMember($objectOrClassName)->isProtected();
}
/**
* Returns whether this member is private
*
* @param object|string $objectOrClassName The object or the class name
*
* @return Boolean
*/
public function isPrivate($objectOrClassName)
{
return $this->getReflectionMember($objectOrClassName)->isPrivate();
}
/**
* Returns whether objects stored in this member should be validated
*
* @return Boolean
*/
public function isCascaded()
{
return $this->cascaded;
}
/**
* Returns whether arrays or traversable objects stored in this member
* should be traversed and validated in each entry
*
* @return Boolean
*/
public function isCollectionCascaded()
{
return $this->collectionCascaded;
}
/**
* Returns whether arrays or traversable objects stored in this member
* should be traversed recursively for inner arrays/traversable objects
*
* @return Boolean
*/
public function isCollectionCascadedDeeply()
{
return $this->collectionCascadedDeeply;
}
/**
* Returns the Reflection instance of the member
*
* @param object|string $objectOrClassName The object or the class name
*
* @return object
*/
public function getReflectionMember($objectOrClassName)
{
$className = is_string($objectOrClassName) ? $objectOrClassName : get_class($objectOrClassName);
if (!isset($this->reflMember[$className])) {
$this->reflMember[$className] = $this->newReflectionMember($objectOrClassName);
}
return $this->reflMember[$className];
}
/**
* Creates a new Reflection instance for the member
*
* @param object|string $objectOrClassName The object or the class name
*
* @return mixed Reflection class
*/
abstract protected function newReflectionMember($objectOrClassName);
}
PK ! +d% % Mapping/Cache/CacheInterface.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Cache;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* Persists ClassMetadata instances in a cache
*
* @author Bernhard Schussek
*/
interface CacheInterface
{
/**
* Returns whether metadata for the given class exists in the cache
*
* @param string $class
*/
public function has($class);
/**
* Returns the metadata for the given class from the cache
*
* @param string $class Class Name
*
* @return ClassMetadata|false A ClassMetadata instance or false on miss
*/
public function read($class);
/**
* Stores a class metadata in the cache
*
* @param ClassMetadata $metadata A Class Metadata
*/
public function write(ClassMetadata $metadata);
}
PK ! Mapping/Cache/ApcCache.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Cache;
use Symfony\Component\Validator\Mapping\ClassMetadata;
class ApcCache implements CacheInterface
{
private $prefix;
public function __construct($prefix)
{
if (!extension_loaded('apc')) {
throw new \RuntimeException('Unable to use ApcCache to cache validator mappings as APC is not enabled.');
}
$this->prefix = $prefix;
}
public function has($class)
{
if (!function_exists('apc_exists')) {
$exists = false;
apc_fetch($this->prefix.$class, $exists);
return $exists;
}
return apc_exists($this->prefix.$class);
}
public function read($class)
{
return apc_fetch($this->prefix.$class);
}
public function write(ClassMetadata $metadata)
{
apc_store($this->prefix.$metadata->getClassName(), $metadata);
}
}
PK ! d#[N Mapping/ClassMetadataFactory.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\MetadataFactoryInterface;
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
/**
* A factory for creating metadata for PHP classes.
*
* @author Bernhard Schussek
*/
class ClassMetadataFactory implements MetadataFactoryInterface
{
/**
* The loader for loading the class metadata
* @var LoaderInterface
*/
protected $loader;
/**
* The cache for caching class metadata
* @var CacheInterface
*/
protected $cache;
protected $loadedClasses = array();
public function __construct(LoaderInterface $loader = null, CacheInterface $cache = null)
{
$this->loader = $loader;
$this->cache = $cache;
}
/**
* {@inheritdoc}
*/
public function getMetadataFor($value)
{
if (!is_object($value) && !is_string($value)) {
throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', gettype($value)));
}
$class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
if (isset($this->loadedClasses[$class])) {
return $this->loadedClasses[$class];
}
if (null !== $this->cache && false !== ($this->loadedClasses[$class] = $this->cache->read($class))) {
return $this->loadedClasses[$class];
}
if (!class_exists($class) && !interface_exists($class)) {
throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class));
}
$metadata = new ClassMetadata($class);
// Include constraints from the parent class
if ($parent = $metadata->getReflectionClass()->getParentClass()) {
$metadata->mergeConstraints($this->getMetadataFor($parent->name));
}
// Include constraints from all implemented interfaces
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) {
continue;
}
$metadata->mergeConstraints($this->getMetadataFor($interface->name));
}
if (null !== $this->loader) {
$this->loader->loadClassMetadata($metadata);
}
if (null !== $this->cache) {
$this->cache->write($metadata);
}
return $this->loadedClasses[$class] = $metadata;
}
/**
* {@inheritdoc}
*/
public function hasMetadataFor($value)
{
if (!is_object($value) && !is_string($value)) {
return false;
}
$class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
if (class_exists($class) || interface_exists($class)) {
return true;
}
return false;
}
}
PK ! ʚ Mapping/Loader/FileLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingException;
abstract class FileLoader extends AbstractLoader
{
protected $file;
/**
* Constructor.
*
* @param string $file The mapping file to load
*
* @throws MappingException if the mapping file does not exist
* @throws MappingException if the mapping file is not readable
*/
public function __construct($file)
{
if (!is_file($file)) {
throw new MappingException(sprintf('The mapping file %s does not exist', $file));
}
if (!is_readable($file)) {
throw new MappingException(sprintf('The mapping file %s is not readable', $file));
}
$this->file = $file;
}
}
PK ! kG+ ! Mapping/Loader/AbstractLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingException;
use Symfony\Component\Validator\Constraint;
abstract class AbstractLoader implements LoaderInterface
{
/**
* Contains all known namespaces indexed by their prefix
* @var array
*/
protected $namespaces = array();
/**
* Adds a namespace alias.
*
* @param string $alias The alias
* @param string $namespace The PHP namespace
*/
protected function addNamespaceAlias($alias, $namespace)
{
$this->namespaces[$alias] = $namespace;
}
/**
* Creates a new constraint instance for the given constraint name.
*
* @param string $name The constraint name. Either a constraint relative
* to the default constraint namespace, or a fully
* qualified class name
* @param mixed $options The constraint options
*
* @return Constraint
*
* @throws MappingException If the namespace prefix is undefined
*/
protected function newConstraint($name, $options)
{
if (strpos($name, '\\') !== false && class_exists($name)) {
$className = (string) $name;
} elseif (strpos($name, ':') !== false) {
list($prefix, $className) = explode(':', $name, 2);
if (!isset($this->namespaces[$prefix])) {
throw new MappingException(sprintf('Undefined namespace prefix "%s"', $prefix));
}
$className = $this->namespaces[$prefix].$className;
} else {
$className = 'Symfony\\Component\\Validator\\Constraints\\'.$name;
}
return new $className($options);
}
}
PK ! Rᠯ ! Mapping/Loader/XmlFilesLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
/**
* Loads multiple xml mapping files
*
* @author Bulat Shakirzyanov
*
* @see Symfony\Component\Validator\Mapping\Loader\FilesLoader
*/
class XmlFilesLoader extends FilesLoader
{
/**
* {@inheritDoc}
*/
public function getFileLoaderInstance($file)
{
return new XmlFileLoader($file);
}
}
PK ! ? " Mapping/Loader/YamlFilesLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
/**
* Loads multiple yaml mapping files
*
* @author Bulat Shakirzyanov
*
* @see Symfony\Component\Validator\Mapping\Loader\FilesLoader
*/
class YamlFilesLoader extends FilesLoader
{
/**
* {@inheritDoc}
*/
public function getFileLoaderInstance($file)
{
return new YamlFileLoader($file);
}
}
PK ! Mapping/Loader/LoaderChain.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* Calls multiple LoaderInterface instances in a chain
*
* This class accepts multiple instances of LoaderInterface to be passed to the
* constructor. When loadClassMetadata() is called, the same method is called
* in all of these loaders, regardless of whether any of them was
* successful or not.
*
* @author Bernhard Schussek
*/
class LoaderChain implements LoaderInterface
{
protected $loaders;
/**
* Accepts a list of LoaderInterface instances
*
* @param LoaderInterface[] $loaders An array of LoaderInterface instances
*
* @throws MappingException If any of the loaders does not implement LoaderInterface
*/
public function __construct(array $loaders)
{
foreach ($loaders as $loader) {
if (!$loader instanceof LoaderInterface) {
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface', get_class($loader)));
}
}
$this->loaders = $loaders;
}
/**
* {@inheritDoc}
*/
public function loadClassMetadata(ClassMetadata $metadata)
{
$success = false;
foreach ($this->loaders as $loader) {
$success = $loader->loadClassMetadata($metadata) || $success;
}
return $success;
}
}
PK ! Tb % Mapping/Loader/StaticMethodLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
class StaticMethodLoader implements LoaderInterface
{
protected $methodName;
public function __construct($methodName = 'loadValidatorMetadata')
{
$this->methodName = $methodName;
}
/**
* {@inheritDoc}
*/
public function loadClassMetadata(ClassMetadata $metadata)
{
/** @var \ReflectionClass $reflClass */
$reflClass = $metadata->getReflectionClass();
if (!$reflClass->isInterface() && $reflClass->hasMethod($this->methodName)) {
$reflMethod = $reflClass->getMethod($this->methodName);
if ($reflMethod->isAbstract()) {
return false;
}
if (!$reflMethod->isStatic()) {
throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->name, $this->methodName));
}
if ($reflMethod->getDeclaringClass()->name != $reflClass->name) {
return false;
}
$reflMethod->invoke(null, $metadata);
return true;
}
return false;
}
}
PK ! >? ? " Mapping/Loader/LoaderInterface.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Mapping\ClassMetadata;
interface LoaderInterface
{
/**
* Load a Class Metadata.
*
* @param ClassMetadata $metadata A metadata
*
* @return Boolean
*/
public function loadClassMetadata(ClassMetadata $metadata);
}
PK ! * Mapping/Loader/FilesLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
/**
* Creates mapping loaders for array of files.
*
* Abstract class, used by
*
* @author Bulat Shakirzyanov
*
* @see Symfony\Component\Validator\Mapping\Loader\YamlFileLoader
* @see Symfony\Component\Validator\Mapping\Loader\XmlFileLoader
*/
abstract class FilesLoader extends LoaderChain
{
/**
* Array of mapping files.
*
* @param array $paths Array of file paths
*/
public function __construct(array $paths)
{
parent::__construct($this->getFileLoaders($paths));
}
/**
* Array of mapping files.
*
* @param array $paths Array of file paths
*
* @return LoaderInterface[] Array of metadata loaders
*/
protected function getFileLoaders($paths)
{
$loaders = array();
foreach ($paths as $path) {
$loaders[] = $this->getFileLoaderInstance($path);
}
return $loaders;
}
/**
* Takes mapping file path.
*
* @param string $file
*
* @return LoaderInterface
*/
abstract protected function getFileLoaderInstance($file);
}
PK ! TO- - G Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsdnu [
PK ! ;QF1 1 Mapping/Loader/XmlFileLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Config\Util\XmlUtils;
class XmlFileLoader extends FileLoader
{
/**
* An array of SimpleXMLElement instances.
*
* @var \SimpleXMLElement[]
*/
protected $classes = null;
/**
* {@inheritDoc}
*/
public function loadClassMetadata(ClassMetadata $metadata)
{
if (null === $this->classes) {
$this->classes = array();
$xml = $this->parseFile($this->file);
foreach ($xml->namespace as $namespace) {
$this->addNamespaceAlias((string) $namespace['prefix'], trim((string) $namespace));
}
foreach ($xml->class as $class) {
$this->classes[(string) $class['name']] = $class;
}
}
if (isset($this->classes[$metadata->getClassName()])) {
$xml = $this->classes[$metadata->getClassName()];
foreach ($xml->{'group-sequence-provider'} as $provider) {
$metadata->setGroupSequenceProvider(true);
}
foreach ($xml->{'group-sequence'} as $groupSequence) {
if (count($groupSequence->value) > 0) {
$metadata->setGroupSequence($this->parseValues($groupSequence[0]->value));
}
}
foreach ($this->parseConstraints($xml->constraint) as $constraint) {
$metadata->addConstraint($constraint);
}
foreach ($xml->property as $property) {
foreach ($this->parseConstraints($property->constraint) as $constraint) {
$metadata->addPropertyConstraint((string) $property['name'], $constraint);
}
}
foreach ($xml->getter as $getter) {
foreach ($this->parseConstraints($getter->constraint) as $constraint) {
$metadata->addGetterConstraint((string) $getter['property'], $constraint);
}
}
return true;
}
return false;
}
/**
* Parses a collection of "constraint" XML nodes.
*
* @param \SimpleXMLElement $nodes The XML nodes
*
* @return array The Constraint instances
*/
protected function parseConstraints(\SimpleXMLElement $nodes)
{
$constraints = array();
foreach ($nodes as $node) {
if (count($node) > 0) {
if (count($node->value) > 0) {
$options = $this->parseValues($node->value);
} elseif (count($node->constraint) > 0) {
$options = $this->parseConstraints($node->constraint);
} elseif (count($node->option) > 0) {
$options = $this->parseOptions($node->option);
} else {
$options = array();
}
} elseif (strlen((string) $node) > 0) {
$options = trim($node);
} else {
$options = null;
}
$constraints[] = $this->newConstraint((string) $node['name'], $options);
}
return $constraints;
}
/**
* Parses a collection of "value" XML nodes.
*
* @param \SimpleXMLElement $nodes The XML nodes
*
* @return array The values
*/
protected function parseValues(\SimpleXMLElement $nodes)
{
$values = array();
foreach ($nodes as $node) {
if (count($node) > 0) {
if (count($node->value) > 0) {
$value = $this->parseValues($node->value);
} elseif (count($node->constraint) > 0) {
$value = $this->parseConstraints($node->constraint);
} else {
$value = array();
}
} else {
$value = trim($node);
}
if (isset($node['key'])) {
$values[(string) $node['key']] = $value;
} else {
$values[] = $value;
}
}
return $values;
}
/**
* Parses a collection of "option" XML nodes.
*
* @param \SimpleXMLElement $nodes The XML nodes
*
* @return array The options
*/
protected function parseOptions(\SimpleXMLElement $nodes)
{
$options = array();
foreach ($nodes as $node) {
if (count($node) > 0) {
if (count($node->value) > 0) {
$value = $this->parseValues($node->value);
} elseif (count($node->constraint) > 0) {
$value = $this->parseConstraints($node->constraint);
} else {
$value = array();
}
} else {
$value = XmlUtils::phpize($node);
if (is_string($value)) {
$value = trim($value);
}
}
$options[(string) $node['name']] = $value;
}
return $options;
}
/**
* Parse a XML File.
*
* @param string $file Path of file
*
* @return \SimpleXMLElement
*
* @throws MappingException
*/
protected function parseFile($file)
{
try {
$dom = XmlUtils::loadFile($file, __DIR__.'/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd');
} catch (\Exception $e) {
throw new MappingException($e->getMessage(), $e->getCode(), $e);
}
return simplexml_import_dom($dom);
}
}
PK ! lw#Q Q # Mapping/Loader/AnnotationLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Doctrine\Common\Annotations\Reader;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Exception\MappingException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\GroupSequenceProvider;
use Symfony\Component\Validator\Constraint;
class AnnotationLoader implements LoaderInterface
{
protected $reader;
public function __construct(Reader $reader)
{
$this->reader = $reader;
}
/**
* {@inheritDoc}
*/
public function loadClassMetadata(ClassMetadata $metadata)
{
$reflClass = $metadata->getReflectionClass();
$className = $reflClass->name;
$loaded = false;
foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) {
if ($constraint instanceof GroupSequence) {
$metadata->setGroupSequence($constraint->groups);
} elseif ($constraint instanceof GroupSequenceProvider) {
$metadata->setGroupSequenceProvider(true);
} elseif ($constraint instanceof Constraint) {
$metadata->addConstraint($constraint);
}
$loaded = true;
}
foreach ($reflClass->getProperties() as $property) {
if ($property->getDeclaringClass()->name == $className) {
foreach ($this->reader->getPropertyAnnotations($property) as $constraint) {
if ($constraint instanceof Constraint) {
$metadata->addPropertyConstraint($property->name, $constraint);
}
$loaded = true;
}
}
}
foreach ($reflClass->getMethods() as $method) {
if ($method->getDeclaringClass()->name == $className) {
foreach ($this->reader->getMethodAnnotations($method) as $constraint) {
if ($constraint instanceof Callback) {
$constraint->callback = $method->getName();
$constraint->methods = null;
$metadata->addConstraint($constraint);
} elseif ($constraint instanceof Constraint) {
if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) {
$metadata->addGetterConstraint(lcfirst($matches[2]), $constraint);
} else {
throw new MappingException(sprintf('The constraint on "%s::%s" cannot be added. Constraints can only be added on methods beginning with "get" or "is".', $className, $method->name));
}
}
$loaded = true;
}
}
}
return $loaded;
}
}
PK ! 'pk k ! Mapping/Loader/YamlFileLoader.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Yaml\Parser as YamlParser;
class YamlFileLoader extends FileLoader
{
private $yamlParser;
/**
* An array of YAML class descriptions
*
* @var array
*/
protected $classes = null;
/**
* {@inheritDoc}
*/
public function loadClassMetadata(ClassMetadata $metadata)
{
if (null === $this->classes) {
if (!stream_is_local($this->file)) {
throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $this->file));
}
if (!file_exists($this->file)) {
throw new \InvalidArgumentException(sprintf('File "%s" not found.', $this->file));
}
if (null === $this->yamlParser) {
$this->yamlParser = new YamlParser();
}
$this->classes = $this->yamlParser->parse(file_get_contents($this->file));
// empty file
if (null === $this->classes) {
return false;
}
// not an array
if (!is_array($this->classes)) {
throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
}
if (isset($this->classes['namespaces'])) {
foreach ($this->classes['namespaces'] as $alias => $namespace) {
$this->addNamespaceAlias($alias, $namespace);
}
unset($this->classes['namespaces']);
}
}
// TODO validation
if (isset($this->classes[$metadata->getClassName()])) {
$yaml = $this->classes[$metadata->getClassName()];
if (isset($yaml['group_sequence_provider'])) {
$metadata->setGroupSequenceProvider((bool) $yaml['group_sequence_provider']);
}
if (isset($yaml['group_sequence'])) {
$metadata->setGroupSequence($yaml['group_sequence']);
}
if (isset($yaml['constraints']) && is_array($yaml['constraints'])) {
foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
$metadata->addConstraint($constraint);
}
}
if (isset($yaml['properties']) && is_array($yaml['properties'])) {
foreach ($yaml['properties'] as $property => $constraints) {
if (null !== $constraints) {
foreach ($this->parseNodes($constraints) as $constraint) {
$metadata->addPropertyConstraint($property, $constraint);
}
}
}
}
if (isset($yaml['getters']) && is_array($yaml['getters'])) {
foreach ($yaml['getters'] as $getter => $constraints) {
if (null !== $constraints) {
foreach ($this->parseNodes($constraints) as $constraint) {
$metadata->addGetterConstraint($getter, $constraint);
}
}
}
}
return true;
}
return false;
}
/**
* Parses a collection of YAML nodes
*
* @param array $nodes The YAML nodes
*
* @return array An array of values or Constraint instances
*/
protected function parseNodes(array $nodes)
{
$values = array();
foreach ($nodes as $name => $childNodes) {
if (is_numeric($name) && is_array($childNodes) && count($childNodes) == 1) {
$options = current($childNodes);
if (is_array($options)) {
$options = $this->parseNodes($options);
}
$values[] = $this->newConstraint(key($childNodes), $options);
} else {
if (is_array($childNodes)) {
$childNodes = $this->parseNodes($childNodes);
}
$values[$name] = $childNodes;
}
}
return $values;
}
}
PK ! ۔ $ Mapping/BlackholeMetadataFactory.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\MetadataFactoryInterface;
/**
* Simple implementation of MetadataFactoryInterface that can be used when using ValidatorInterface::validateValue().
*
* @author Fabien Potencier
*/
class BlackholeMetadataFactory implements MetadataFactoryInterface
{
/**
* @inheritdoc
*/
public function getMetadataFor($value)
{
throw new \LogicException('BlackholeClassMetadataFactory only works with ValidatorInterface::validateValue().');
}
/**
* @inheritdoc
*/
public function hasMetadataFor($value)
{
return false;
}
}
PK ! L8
ValidationVisitorInterface.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
/**
* Validates values against constraints defined in {@link MetadataInterface}
* instances.
*
* This interface is an implementation of the Visitor design pattern. A value
* is validated by first passing it to the {@link validate} method. That method
* will determine the matching {@link MetadataInterface} for validating the
* value. It then calls the {@link MetadataInterface::accept} method of that
* metadata. accept() does two things:
*
*
* - It calls {@link visit} to validate the value against the constraints of
* the metadata.
* - It calls accept() on all nested metadata instances with the
* corresponding values extracted from the current value. For example, if the
* current metadata represents a class and the current value is an object of
* that class, the metadata contains nested instances for each property of that
* class. It forwards the call to these nested metadata with the values of the
* corresponding properties in the original object.
*
*
* @author Bernhard Schussek
*/
interface ValidationVisitorInterface
{
/**
* Validates a value.
*
* If the value is an array or a traversable object, you can set the
* parameter $traverse to true in order to run through
* the collection and validate each element. If these elements can be
* collections again and you want to traverse them recursively, set the
* parameter $deep to true as well.
*
* If you set $traversable to true, the visitor will
* nevertheless try to find metadata for the collection and validate its
* constraints. If no such metadata is found, the visitor ignores that and
* only iterates the collection.
*
* If you don't set $traversable to true and the visitor
* does not find metadata for the given value, it will fail with an
* exception.
*
* @param mixed $value The value to validate.
* @param string $group The validation group to validate.
* @param string $propertyPath The current property path in the validation graph.
* @param Boolean $traverse Whether to traverse the value if it is traversable.
* @param Boolean $deep Whether to traverse nested traversable values recursively.
*
* @throws Exception\NoSuchMetadataException If no metadata can be found for
* the given value.
*/
public function validate($value, $group, $propertyPath, $traverse = false, $deep = false);
/**
* Validates a value against the constraints defined in some metadata.
*
* This method implements the Visitor design pattern. See also
* {@link ValidationVisitorInterface}.
*
* @param MetadataInterface $metadata The metadata holding the constraints.
* @param mixed $value The value to validate.
* @param string $group The validation group to validate.
* @param string $propertyPath The current property path in the validation graph.
*/
public function visit(MetadataInterface $metadata, $value, $group, $propertyPath);
}
PK ! QV V Exception/MappingException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
class MappingException extends ValidatorException
{
}
PK ! y $ Exception/BadMethodCallException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
/**
* Base BadMethodCallException for the Validator component.
*
* @author Bernhard Schussek
*/
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}
PK ! LЉR R % Exception/InvalidOptionsException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
class InvalidOptionsException extends ValidatorException
{
private $options;
public function __construct($message, array $options)
{
parent::__construct($message);
$this->options = $options;
}
public function getOptions()
{
return $this->options;
}
}
PK ! k1+W W Exception/ValidatorException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
class ValidatorException extends \RuntimeException
{
}
PK ! b< < % Exception/UnexpectedTypeException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
class UnexpectedTypeException extends ValidatorException
{
public function __construct($value, $expectedType)
{
parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value)));
}
}
PK ! 1"c c + Exception/ConstraintDefinitionException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
class ConstraintDefinitionException extends ValidatorException
{
}
PK ! T Exception/ExceptionInterface.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
/**
* Base ExceptionInterface for the Validator component.
*
* @author Bernhard Schussek
*/
interface ExceptionInterface
{
}
PK ! z Exception/RuntimeException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
/**
* Base RuntimeException for the Validator component.
*
* @author Bernhard Schussek
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}
PK ! x % Exception/NoSuchMetadataException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
/**
* @author Bernhard Schussek
*/
class NoSuchMetadataException extends ValidatorException
{
}
PK ! uR R % Exception/MissingOptionsException.phpnu [
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Exception;
class MissingOptionsException extends ValidatorException
{
private $options;
public function __construct($message, array $options)
{
parent::__construct($message);
$this->options = $options;
}
public function getOptions()
{
return $this->options;
}
}
PK ! M#^ ^ &