Browse Source

Rename Validator::isScalar() to Validator::scalar()

chinpei215 8 years ago
parent
commit
4fd0bc58d3
2 changed files with 7 additions and 5 deletions
  1. 4 2
      src/Validation/Validator.php
  2. 3 3
      tests/TestCase/Validation/ValidatorTest.php

+ 4 - 2
src/Validation/Validator.php

@@ -1607,6 +1607,7 @@ class Validator implements ArrayAccess, IteratorAggregate, Countable
      * @param string|null $message The error message when the rule fails.
      * @param string|callable|null $when Either 'create' or 'update' or a callable that returns
      *   true when the validation rule should be applied.
+     * @see \Cake\Validation\Validation::isArray()
      * @return $this
      */
     public function isArray($field, $message = null, $when = null)
@@ -1625,13 +1626,14 @@ class Validator implements ArrayAccess, IteratorAggregate, Countable
      * @param string|null $message The error message when the rule fails.
      * @param string|callable|null $when Either 'create' or 'update' or a callable that returns
      *   true when the validation rule should be applied.
+     * @see \Cake\Validation\Validation::isScalar()
      * @return $this
      */
-    public function isScalar($field, $message = null, $when = null)
+    public function scalar($field, $message = null, $when = null)
     {
         $extra = array_filter(['on' => $when, 'message' => $message]);
 
-        return $this->add($field, 'isScalar', $extra + [
+        return $this->add($field, 'scalar', $extra + [
                 'rule' => 'isScalar'
             ]);
     }

+ 3 - 3
tests/TestCase/Validation/ValidatorTest.php

@@ -1801,14 +1801,14 @@ class ValidatorTest extends TestCase
     }
 
     /**
-     * Tests the isScalar proxy method
+     * Tests the scalar proxy method
      *
      * @return void
      */
-    public function testIsScalar()
+    public function testScalar()
     {
         $validator = new Validator();
-        $validator->isScalar('username');
+        $validator->scalar('username');
         $this->assertEmpty($validator->errors(['username' => 'scalar']));
         $this->assertNotEmpty($validator->errors(['username' => ['array']]));
     }