Use short array syntax

[MAILPOET-2090]
This commit is contained in:
Pavel Dohnal
2019-05-20 13:48:48 +02:00
committed by M. Shull
parent 9f16cb6a5f
commit 5da7110eb6
385 changed files with 40133 additions and 40131 deletions

View File

@ -6,25 +6,25 @@ use MailPoet\WP\Functions as WPFunctions;
class ErrorResponse extends Response {
public $errors;
function __construct($errors = array(), $meta = array(), $status = self::STATUS_NOT_FOUND) {
function __construct($errors = [], $meta = [], $status = self::STATUS_NOT_FOUND) {
parent::__construct($status, $meta);
$this->errors = $this->formatErrors($errors);
}
function getData() {
return (empty($this->errors)) ? null : array('errors' => $this->errors);
return (empty($this->errors)) ? null : ['errors' => $this->errors];
}
function formatErrors($errors = array()) {
function formatErrors($errors = []) {
return array_map(function($error, $message) {
// sanitize SQL error
if (preg_match('/^SQLSTATE/i', $message)) {
$message = WPFunctions::get()->__('An unknown error occurred.', 'mailpoet');
}
return array(
return [
'error' => $error,
'message' => $message
);
'message' => $message,
];
}, array_keys($errors), array_values($errors));
}
}