From 866242643f5ea4da2a567a618ebf7a5a8005b7ad Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 17 May 2015 22:13:04 +0200 Subject: [PATCH] Deprecate notEmpty in favor of notBlank. --- lib/Cake/Test/Case/Utility/ValidationTest.php | 34 +++++++++---------- lib/Cake/Utility/Validation.php | 17 ++++++++-- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 7126f6ecf..332b1b10b 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -129,15 +129,15 @@ class ValidationTest extends CakeTestCase { * @return void */ public function testNotEmpty() { - $this->assertTrue(Validation::notEmpty('abcdefg')); - $this->assertTrue(Validation::notEmpty('fasdf ')); - $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla')); - $this->assertTrue(Validation::notEmpty('abçďĕʑʘπй')); - $this->assertTrue(Validation::notEmpty('José')); - $this->assertTrue(Validation::notEmpty('é')); - $this->assertTrue(Validation::notEmpty('π')); - $this->assertFalse(Validation::notEmpty("\t ")); - $this->assertFalse(Validation::notEmpty("")); + $this->assertTrue(Validation::notBlank('abcdefg')); + $this->assertTrue(Validation::notBlank('fasdf ')); + $this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla')); + $this->assertTrue(Validation::notBlank('abçďĕʑʘπй')); + $this->assertTrue(Validation::notBlank('José')); + $this->assertTrue(Validation::notBlank('é')); + $this->assertTrue(Validation::notBlank('π')); + $this->assertFalse(Validation::notBlank("\t ")); + $this->assertFalse(Validation::notBlank("")); } /** @@ -147,14 +147,14 @@ class ValidationTest extends CakeTestCase { */ public function testNotEmptyISO88591AppEncoding() { Configure::write('App.encoding', 'ISO-8859-1'); - $this->assertTrue(Validation::notEmpty('abcdefg')); - $this->assertTrue(Validation::notEmpty('fasdf ')); - $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla')); - $this->assertTrue(Validation::notEmpty('abçďĕʑʘπй')); - $this->assertTrue(Validation::notEmpty('José')); - $this->assertTrue(Validation::notEmpty(utf8_decode('José'))); - $this->assertFalse(Validation::notEmpty("\t ")); - $this->assertFalse(Validation::notEmpty("")); + $this->assertTrue(Validation::notBlank('abcdefg')); + $this->assertTrue(Validation::notBlank('fasdf ')); + $this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla')); + $this->assertTrue(Validation::notBlank('abçďĕʑʘπй')); + $this->assertTrue(Validation::notBlank('José')); + $this->assertTrue(Validation::notBlank(utf8_decode('José'))); + $this->assertFalse(Validation::notBlank("\t ")); + $this->assertFalse(Validation::notBlank("")); } /** diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index a2243694d..640f8b1ac 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -48,6 +48,19 @@ class Validation { */ public static $errors = array(); +/** + * Backwards compatibility wrapper for Validation::notBlank(). + * + * @param string|array $check Value to check. + * @return bool Success. + * @deprecated 2.7.0 Use Validation::notBlank() instead. + * @see Validation::notBlank() + */ + public function notEmpty($check) { + trigger_error('Validation::notEmpty() is deprecated. Use Validation::notBlank() instead.', E_USER_DEPRECATED); + return self::notBlank($check); + } + /** * Checks that a string contains something other than whitespace * @@ -59,7 +72,7 @@ class Validation { * @param string|array $check Value to check * @return bool Success */ - public static function notEmpty($check) { + public static function notBlank($check) { if (is_array($check)) { extract(self::_defaults($check)); } @@ -143,7 +156,7 @@ class Validation { * Returns true if $check is in the proper credit card format. * * @param string|array $check credit card number to validate - * @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit + * @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit * cards * if an array is used only the values of the array are checked. * Example: array('amex', 'bankcard', 'maestro')