Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## unreleased
* Make Error\Validation jsonSerializable

## 6.5.1
* Address PHP 8.1 Deprecation warnings

Expand Down
18 changes: 17 additions & 1 deletion lib/Braintree/Error/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Braintree\Error;

use Braintree\Util;
use JsonSerializable;

/**
* error object returned as part of a validation error collection
Expand All @@ -13,7 +14,7 @@
* // phpcs:ignore Generic.Files.LineLength
* See our {@link https://developer.paypal.com/braintree/docs/reference/general/result-objects#error-results developer docs} for more information
*/
class Validation
class Validation implements JsonSerializable
{
private $_attribute;
private $_code;
Expand All @@ -40,4 +41,19 @@ public function __get($name)
$varName = "_$name";
return isset($this->$varName) ? $this->$varName : null;
}

/**
* Implementation of JsonSerializable
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return array(
'code' => $this->__get('code'),
'attribute' => $this->__get('attribute'),
'message' => $this->__get('message')
);
Comment on lines +53 to +57

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return array(
'code' => $this->__get('code'),
'attribute' => $this->__get('attribute'),
'message' => $this->__get('message')
);
return [
'code' => $this->__get('code'),
'attribute' => $this->__get('attribute'),
'message' => $this->__get('message'),
];

}
}