Explorar o código

[Validator] renamed methods that do not follow CS

requiredOptions -> getRequiredOptions
targets -> getTargets
defaultOption -> getDefaultOption
Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
f92055ce42
Modificáronse 38 ficheiros con 73 adicións e 73 borrados
  1. 3 3
      src/Symfony/Bundle/DoctrineMongoDBBundle/Validator/Constraints/Unique.php
  2. 3 3
      src/Symfony/Component/Form/Configurable.php
  3. 11 11
      src/Symfony/Component/Validator/Constraint.php
  4. 3 3
      src/Symfony/Component/Validator/Constraints/All.php
  5. 1 1
      src/Symfony/Component/Validator/Constraints/Blank.php
  6. 3 3
      src/Symfony/Component/Validator/Constraints/Callback.php
  7. 2 2
      src/Symfony/Component/Validator/Constraints/Choice.php
  8. 2 2
      src/Symfony/Component/Validator/Constraints/Collection.php
  9. 1 1
      src/Symfony/Component/Validator/Constraints/Country.php
  10. 1 1
      src/Symfony/Component/Validator/Constraints/Date.php
  11. 1 1
      src/Symfony/Component/Validator/Constraints/DateTime.php
  12. 1 1
      src/Symfony/Component/Validator/Constraints/Email.php
  13. 1 1
      src/Symfony/Component/Validator/Constraints/False.php
  14. 1 1
      src/Symfony/Component/Validator/Constraints/File.php
  15. 1 1
      src/Symfony/Component/Validator/Constraints/Ip.php
  16. 1 1
      src/Symfony/Component/Validator/Constraints/Language.php
  17. 1 1
      src/Symfony/Component/Validator/Constraints/Locale.php
  18. 3 3
      src/Symfony/Component/Validator/Constraints/Max.php
  19. 3 3
      src/Symfony/Component/Validator/Constraints/MaxLength.php
  20. 3 3
      src/Symfony/Component/Validator/Constraints/Min.php
  21. 3 3
      src/Symfony/Component/Validator/Constraints/MinLength.php
  22. 1 1
      src/Symfony/Component/Validator/Constraints/NotBlank.php
  23. 1 1
      src/Symfony/Component/Validator/Constraints/NotNull.php
  24. 1 1
      src/Symfony/Component/Validator/Constraints/Null.php
  25. 3 3
      src/Symfony/Component/Validator/Constraints/Regex.php
  26. 1 1
      src/Symfony/Component/Validator/Constraints/Time.php
  27. 1 1
      src/Symfony/Component/Validator/Constraints/True.php
  28. 3 3
      src/Symfony/Component/Validator/Constraints/Type.php
  29. 1 1
      src/Symfony/Component/Validator/Constraints/Url.php
  30. 1 1
      src/Symfony/Component/Validator/Constraints/Valid.php
  31. 1 1
      src/Symfony/Component/Validator/Mapping/ClassMetadata.php
  32. 1 1
      src/Symfony/Component/Validator/Mapping/MemberMetadata.php
  33. 1 1
      tests/Symfony/Tests/Component/Validator/Fixtures/ClassConstraint.php
  34. 3 3
      tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintA.php
  35. 1 1
      tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintB.php
  36. 2 2
      tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintC.php
  37. 1 1
      tests/Symfony/Tests/Component/Validator/Fixtures/FailingConstraint.php
  38. 1 1
      tests/Symfony/Tests/Component/Validator/Fixtures/PropertyConstraint.php

+ 3 - 3
src/Symfony/Bundle/DoctrineMongoDBBundle/Validator/Constraints/Unique.php

@@ -24,12 +24,12 @@ class Unique extends Constraint
     public $path;
     public $documentManager;
 
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'path';
     }
 
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('path');
     }
@@ -39,7 +39,7 @@ class Unique extends Constraint
         return 'doctrine_odm.mongodb.unique';
     }
 
-    public function targets()
+    public function getTargets()
     {
         return Constraint::CLASS_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Form/Configurable.php

@@ -44,7 +44,7 @@ abstract class Configurable
      * The names of the required options
      * @var array
      */
-    private $requiredOptions = array();
+    private $getRequiredOptions = array();
 
     /**
      * Reads, validates and stores the given options
@@ -63,7 +63,7 @@ abstract class Configurable
         }
 
         // check required options
-        if ($diff = array_diff_key($this->requiredOptions, $this->options)) {
+        if ($diff = array_diff_key($this->getRequiredOptions, $this->options)) {
             throw new MissingOptionsException(sprintf('%s requires the following options: \'%s\'.', get_class($this), implode('", "', array_keys($diff))), array_keys($diff));
         }
     }
@@ -117,7 +117,7 @@ abstract class Configurable
     protected function addRequiredOption($name, array $allowedValues = array())
     {
         $this->knownOptions[$name] = true;
-        $this->requiredOptions[$name] = true;
+        $this->getRequiredOptions[$name] = true;
 
         // only test if the option is set, otherwise an error will be thrown
         // anyway

+ 11 - 11
src/Symfony/Component/Validator/Constraint.php

@@ -58,12 +58,12 @@ abstract class Constraint
      * existing properties in this class. The values should be the value for these
      * properties.
      *
-     * Alternatively you can override the method defaultOption() to return the
+     * 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
-     * requiredOptions() to return the names of these options. If any
+     * 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)
@@ -73,15 +73,15 @@ abstract class Constraint
      * @throws InvalidOptionsException       When you pass the names of non-existing
      *                                       options
      * @throws MissingOptionsException       When you don't pass any of the options
-     *                                       returned by requiredOptions()
+     *                                       returned by getRequiredOptions()
      * @throws ConstraintDefinitionException When you don't pass an associative
-     *                                       array, but defaultOption() returns
+     *                                       array, but getDefaultOption() returns
      *                                       NULL
      */
     public function __construct($options = null)
     {
         $invalidOptions = array();
-        $missingOptions = array_flip((array)$this->requiredOptions());
+        $missingOptions = array_flip((array)$this->getRequiredOptions());
 
         if (is_array($options) && count($options) == 1 && isset($options['value'])) {
             $options = $options['value'];
@@ -97,7 +97,7 @@ abstract class Constraint
                 }
             }
         } else if (null !== $options && ! (is_array($options) && count($options) === 0)) {
-            $option = $this->defaultOption();
+            $option = $this->getDefaultOption();
 
             if (null === $option) {
                 throw new ConstraintDefinitionException(
@@ -158,7 +158,7 @@ abstract class Constraint
      * @return string
      * @see __construct()
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return null;
     }
@@ -171,7 +171,7 @@ abstract class Constraint
      * @return array
      * @see __construct()
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array();
     }
@@ -187,7 +187,7 @@ abstract class Constraint
      */
     public function validatedBy()
     {
-        return get_class($this) . 'Validator';
+        return get_class($this).'Validator';
     }
 
     /**
@@ -199,5 +199,5 @@ abstract class Constraint
      *
      * @return string|array  One or more constant values
      */
-    abstract public function targets();
-}
+    abstract public function getTargets();
+}

+ 3 - 3
src/Symfony/Component/Validator/Constraints/All.php

@@ -15,12 +15,12 @@ class All extends \Symfony\Component\Validator\Constraint
 {
     public $constraints = array();
 
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'constraints';
     }
 
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('constraints');
     }
@@ -28,7 +28,7 @@ class All extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Blank.php

@@ -18,7 +18,7 @@ class Blank extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Validator/Constraints/Callback.php

@@ -18,7 +18,7 @@ class Callback extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('methods');
     }
@@ -26,7 +26,7 @@ class Callback extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'methods';
     }
@@ -34,7 +34,7 @@ class Callback extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::CLASS_CONSTRAINT;
     }

+ 2 - 2
src/Symfony/Component/Validator/Constraints/Choice.php

@@ -25,7 +25,7 @@ class Choice extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'choices';
     }
@@ -33,7 +33,7 @@ class Choice extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 2 - 2
src/Symfony/Component/Validator/Constraints/Collection.php

@@ -19,7 +19,7 @@ class Collection extends \Symfony\Component\Validator\Constraint
     public $extraFieldsMessage = 'The fields {{ fields }} were not expected';
     public $missingFieldsMessage = 'The fields {{ fields }} are missing';
 
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('fields');
     }
@@ -27,7 +27,7 @@ class Collection extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Country.php

@@ -18,7 +18,7 @@ class Country extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Date.php

@@ -18,7 +18,7 @@ class Date extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/DateTime.php

@@ -18,7 +18,7 @@ class DateTime extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Email.php

@@ -19,7 +19,7 @@ class Email extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/False.php

@@ -18,7 +18,7 @@ class False extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/File.php

@@ -23,7 +23,7 @@ class File extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Ip.php

@@ -49,7 +49,7 @@ class Ip extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Language.php

@@ -18,7 +18,7 @@ class Language extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Locale.php

@@ -18,7 +18,7 @@ class Locale extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Validator/Constraints/Max.php

@@ -19,7 +19,7 @@ class Max extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'limit';
     }
@@ -27,7 +27,7 @@ class Max extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('limit');
     }
@@ -35,7 +35,7 @@ class Max extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Validator/Constraints/MaxLength.php

@@ -20,7 +20,7 @@ class MaxLength extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'limit';
     }
@@ -28,7 +28,7 @@ class MaxLength extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('limit');
     }
@@ -36,7 +36,7 @@ class MaxLength extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Validator/Constraints/Min.php

@@ -19,7 +19,7 @@ class Min extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'limit';
     }
@@ -27,7 +27,7 @@ class Min extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('limit');
     }
@@ -35,7 +35,7 @@ class Min extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Validator/Constraints/MinLength.php

@@ -20,7 +20,7 @@ class MinLength extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'limit';
     }
@@ -28,7 +28,7 @@ class MinLength extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('limit');
     }
@@ -36,7 +36,7 @@ class MinLength extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/NotBlank.php

@@ -18,7 +18,7 @@ class NotBlank extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/NotNull.php

@@ -18,7 +18,7 @@ class NotNull extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Null.php

@@ -18,7 +18,7 @@ class Null extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Validator/Constraints/Regex.php

@@ -20,7 +20,7 @@ class Regex extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'pattern';
     }
@@ -28,7 +28,7 @@ class Regex extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('pattern');
     }
@@ -36,7 +36,7 @@ class Regex extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Time.php

@@ -18,7 +18,7 @@ class Time extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/True.php

@@ -18,7 +18,7 @@ class True extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 3 - 3
src/Symfony/Component/Validator/Constraints/Type.php

@@ -19,7 +19,7 @@ class Type extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'type';
     }
@@ -27,7 +27,7 @@ class Type extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('type');
     }
@@ -35,7 +35,7 @@ class Type extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Url.php

@@ -19,7 +19,7 @@ class Url extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Valid.php

@@ -20,7 +20,7 @@ class Valid extends \Symfony\Component\Validator\Constraint
     /**
      * {@inheritDoc}
      */
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }

+ 1 - 1
src/Symfony/Component/Validator/Mapping/ClassMetadata.php

@@ -96,7 +96,7 @@ class ClassMetadata extends ElementMetadata
      */
     public function addConstraint(Constraint $constraint)
     {
-        if (!in_array(Constraint::CLASS_CONSTRAINT, (array)$constraint->targets())) {
+        if (!in_array(Constraint::CLASS_CONSTRAINT, (array)$constraint->getTargets())) {
             throw new ConstraintDefinitionException(sprintf(
                 'The constraint %s cannot be put on classes',
                 get_class($constraint)

+ 1 - 1
src/Symfony/Component/Validator/Mapping/MemberMetadata.php

@@ -44,7 +44,7 @@ abstract class MemberMetadata extends ElementMetadata
      */
     public function addConstraint(Constraint $constraint)
     {
-        if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array)$constraint->targets())) {
+        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)

+ 1 - 1
tests/Symfony/Tests/Component/Validator/Fixtures/ClassConstraint.php

@@ -6,7 +6,7 @@ use Symfony\Component\Validator\Constraint;
 
 class ClassConstraint extends Constraint
 {
-    public function targets()
+    public function getTargets()
     {
         return self::CLASS_CONSTRAINT;
     }

+ 3 - 3
tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintA.php

@@ -9,13 +9,13 @@ class ConstraintA extends Constraint
     public $property1;
     public $property2;
 
-    public function defaultOption()
+    public function getDefaultOption()
     {
         return 'property2';
     }
 
-    public function targets()
+    public function getTargets()
     {
         return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT);
     }
-}
+}

+ 1 - 1
tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintB.php

@@ -6,7 +6,7 @@ use Symfony\Component\Validator\Constraint;
 
 class ConstraintB extends Constraint {
 
-    public function targets()
+    public function getTargets()
     {
         return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT);
     }

+ 2 - 2
tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintC.php

@@ -8,12 +8,12 @@ class ConstraintC extends Constraint
 {
     public $option1;
 
-    public function requiredOptions()
+    public function getRequiredOptions()
     {
         return array('option1');
     }
 
-    public function targets()
+    public function getTargets()
     {
         return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT);
     }

+ 1 - 1
tests/Symfony/Tests/Component/Validator/Fixtures/FailingConstraint.php

@@ -8,7 +8,7 @@ class FailingConstraint extends Constraint
 {
     public $message = '';
 
-    public function targets()
+    public function getTargets()
     {
         return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT);
     }

+ 1 - 1
tests/Symfony/Tests/Component/Validator/Fixtures/PropertyConstraint.php

@@ -6,7 +6,7 @@ use Symfony\Component\Validator\Constraint;
 
 class PropertyConstraint extends Constraint
 {
-    public function targets()
+    public function getTargets()
     {
         return self::PROPERTY_CONSTRAINT;
     }