From 8bb80cb84365982704d31e1fb91e01d51669536e Mon Sep 17 00:00:00 2001 From: japatel Date: Mon, 8 Dec 2014 11:01:41 -0600 Subject: [PATCH] Returns False on Validation for Access Modifier on generic PPModel object - Fixes #171 Issue --- lib/PayPal/Validation/ModelAccessorValidator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/PayPal/Validation/ModelAccessorValidator.php b/lib/PayPal/Validation/ModelAccessorValidator.php index 2810e17..67c131d 100644 --- a/lib/PayPal/Validation/ModelAccessorValidator.php +++ b/lib/PayPal/Validation/ModelAccessorValidator.php @@ -26,8 +26,12 @@ class ModelAccessorValidator if ($mode != 'disabled') { //If the mode is disabled, bypass the validation foreach (array('set' . $attributeName, 'get' . $attributeName) as $methodName) { + if (get_class($class) == "PayPal\\Common\\PPModel") { + // Silently return false on cases where you are using PPModel instance directly + return false; + } //Check if both getter and setter exists for given attribute - if (!method_exists($class, $methodName)) { + elseif (!method_exists($class, $methodName)) { //Delegate the error based on the choice $className = is_object($class) ? get_class($class) : (string)$class; $errorMessage = "Missing Accessor: $className:$methodName. Please let us know by creating an issue at https://github.com/paypal/PayPal-PHP-SDK/issues";