From ed9d2d312c9cc526444560d31c0780549f4dbc0e Mon Sep 17 00:00:00 2001 From: Jaspaul Bola Date: Sat, 28 Feb 2015 15:39:05 -0500 Subject: [PATCH] Fix for laravel 5.0 --- composer.json | 7 +-- .../Validation/ContextualValidator.php | 48 +++++++++---------- src/Crhayes/Validation/GroupedValidator.php | 24 +++++----- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/composer.json b/composer.json index e11ec94..f4f8b0a 100644 --- a/composer.json +++ b/composer.json @@ -9,9 +9,10 @@ ], "require": { "php": ">=5.3.0", - "illuminate/support": "~4.1", - "illuminate/http": "~4.1", - "illuminate/validation": "~4.1" + "illuminate/support": "~5.0", + "illuminate/http": "~5.0", + "illuminate/validation": "~5.0", + "illuminate/contracts": "~5.0" }, "require-dev": { "mockery/mockery": "0.7.*" diff --git a/src/Crhayes/Validation/ContextualValidator.php b/src/Crhayes/Validation/ContextualValidator.php index ddaa842..6361c08 100644 --- a/src/Crhayes/Validation/ContextualValidator.php +++ b/src/Crhayes/Validation/ContextualValidator.php @@ -4,61 +4,61 @@ use Crhayes\Validation\Exceptions\ReplacementBindingException; use Crhayes\Validation\Exceptions\ValidatorContextException; -use Illuminate\Support\Contracts\MessageProviderInterface; +use Illuminate\Contracts\Support\MessageProvider; use Input; use Validator; -abstract class ContextualValidator implements MessageProviderInterface +abstract class ContextualValidator implements MessageProvider { const DEFAULT_KEY = 'default'; /** * Store the attributes we are validating. - * + * * @var array */ protected $attributes = array(); /** * Store the validation rules. - * + * * @var array */ protected $rules = array(); /** * Store any custom messages for validation rules. - * + * * @var array */ protected $messages = array(); /** * Store any contexts we are validating within. - * + * * @var array */ protected $contexts = array(); /** * Store replacement values for any bindings in our rules. - * + * * @var array */ protected $replacements = array(); /** * Store any validation messages generated. - * + * * @var array */ protected $errors = array(); /** * Our constructor will store the attributes we are validating, and - * may also take as a second parameter the contexts within which + * may also take as a second parameter the contexts within which * we are validating. - * + * * @param array $attributes * @param mixed $context */ @@ -71,7 +71,7 @@ public function __construct($attributes = null, $context = null) /** * Static shorthand for creating a new validator. - * + * * @param mixed $validator * @return Crhayes\Validation\GroupedValidator */ @@ -83,7 +83,7 @@ public static function make($attributes = null, $context = null) /** * Stub method that can be extended by child classes. * Passes a validator object and allows for adding complex conditional validations. - * + * * @param \Illuminate\Validation\Validator $validator */ protected function addConditionalRules($validator) {} @@ -113,13 +113,13 @@ public function getAttributes() /** * Add a validation context. - * + * * @param array $context */ public function addContext($context) { $context = is_array($context) ? $context : array($context); - + $this->contexts = array_merge($this->contexts, $context); return $this; @@ -140,7 +140,7 @@ public function setContext($context) /** * Retrieve the valiation context. - * + * * @return array */ public function getContexts() @@ -150,7 +150,7 @@ public function getContexts() /** * Bind a replacement value to a placeholder in a rule. - * + * * @param string $field * @param array $replacement * @return Crhayes\Validation\ContextualValidator @@ -164,7 +164,7 @@ public function bindReplacement($field, array $replacement) /** * Get a bound replacement by key. - * + * * @param string $key * @return array */ @@ -175,7 +175,7 @@ public function getReplacement($key) /** * Perform a validation check against our attributes. - * + * * @return boolean */ public function passes() @@ -215,7 +215,7 @@ public function getMessageBag() /** * Return any errors. - * + * * @return Illuminate\Support\MessageBag */ public function errors() @@ -227,7 +227,7 @@ public function errors() /** * Get the validaton rules within the context of the current validation. - * + * * @return array */ protected function getRulesInContext() @@ -242,8 +242,8 @@ protected function getRulesInContext() { throw new ValidatorContextException( sprintf( - "'%s' does not contain the validation context '%s'", - get_called_class(), + "'%s' does not contain the validation context '%s'", + get_called_class(), $context ) ); @@ -258,7 +258,7 @@ protected function getRulesInContext() /** * Spin through our contextual rules array and bind any replacement * values to placeholders within the rules. - * + * * @param array $rules * @return array */ @@ -296,7 +296,7 @@ protected function bindReplacements($rules) /** * Check if the current validation has a context. - * + * * @return boolean */ protected function hasContext() diff --git a/src/Crhayes/Validation/GroupedValidator.php b/src/Crhayes/Validation/GroupedValidator.php index 04a9835..9c2febd 100644 --- a/src/Crhayes/Validation/GroupedValidator.php +++ b/src/Crhayes/Validation/GroupedValidator.php @@ -3,21 +3,21 @@ namespace Crhayes\Validation; use Crhayes\Validation\Exceptions\MissingValidatorException; -use Illuminate\Support\Contracts\MessageProviderInterface; +use Illuminate\Contracts\Support\MessageProvider; class GroupedValidator { /** * An array of Validator objects we will spin through * when running our grouped validation. - * + * * @var array */ protected $validators = array(); /** * An array of errors returned from all of the validators. - * + * * @var array */ protected $errors = array(); @@ -25,7 +25,7 @@ class GroupedValidator /** * Create a new GroupedValidator, with the option of specifying * either a single validator object or an array of validators. - * + * * @param mixed $validator */ public function __construct($validator = array()) @@ -35,7 +35,7 @@ public function __construct($validator = array()) /** * Static shorthand for creating a new grouped validator. - * + * * @param mixed $validator * @return Crhayes\Validation\GroupedValidator */ @@ -47,13 +47,13 @@ public static function make($validator = array()) /** * Add a validator to spin through. Accepts either a single * Validator object or an array of validators. - * + * * @param mixed $validator */ - public function addValidator(MessageProviderInterface $validator) + public function addValidator(MessageProvider $validator) { $validator = is_array($validator) ? $validator : array($validator); - + $this->validators = array_merge($this->validators, $validator); return $this; @@ -61,7 +61,7 @@ public function addValidator(MessageProviderInterface $validator) /** * Perform a check to see if all of the validators have passed. - * + * * @return boolean */ public function passes() @@ -78,10 +78,10 @@ public function passes() return (count($this->errors)) ? false : true; } - + /** * Perform a check to see if any of the validators have failed. - * + * * @return boolean */ public function fails() @@ -91,7 +91,7 @@ public function fails() /** * Return the combined errors from all validators. - * + * * @return Illuminate\Support\MessageBag */ public function errors()