From 9c48355f8904927150840e29890af7051018351b Mon Sep 17 00:00:00 2001 From: Olivier Paroz Date: Wed, 14 Jan 2015 23:57:22 +0100 Subject: Use shorter syntax for arrays (5.4+ only) --- utility/normalizer.php | 14 +++++++------- utility/smarterlogger.php | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'utility') diff --git a/utility/normalizer.php b/utility/normalizer.php index c039cf03..45140944 100644 --- a/utility/normalizer.php +++ b/utility/normalizer.php @@ -35,11 +35,11 @@ class Normalizer { if (!is_array($scalar)) { return $scalar; } - $decisionArray = array( + $decisionArray = [ $this->normalizeTraversable($data, $depth), $this->normalizeObject($data, $depth), $this->normalizeResource($data), - ); + ]; foreach ($decisionArray as $dataType) { if ($dataType !== null) { @@ -69,7 +69,7 @@ class Normalizer { return $data; } - return array(); + return []; } /** @@ -99,7 +99,7 @@ class Normalizer { private function normalizeTraversableElement($data, $depth) { $maxArrayRecursion = 20; $count = 1; - $normalized = array(); + $normalized = []; foreach ($data as $key => $value) { if ($count++ >= $maxArrayRecursion) { $normalized['...'] = @@ -136,7 +136,7 @@ class Normalizer { } // Don't convert to json here as we would double encode - return array(sprintf("[object] (%s)", get_class($data)), $response); + return [sprintf("[object] (%s)", get_class($data)), $response]; } return null; @@ -150,12 +150,12 @@ class Normalizer { * @return string[] */ private function normalizeException(\Exception $exception) { - $data = array( + $data = [ 'class' => get_class($exception), 'message' => $exception->getMessage(), 'code' => $exception->getCode(), 'file' => $exception->getFile() . ':' . $exception->getLine(), - ); + ]; $trace = $exception->getTraceAsString(); $data['trace'][] = $trace; diff --git a/utility/smarterlogger.php b/utility/smarterlogger.php index 4e4a1b20..72dd788a 100644 --- a/utility/smarterlogger.php +++ b/utility/smarterlogger.php @@ -56,7 +56,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function emergency($message, array $context = array()) { + public function emergency($message, array $context = []) { $this->log(\OCP\Util::FATAL, $message, $context); } @@ -68,7 +68,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function alert($message, array $context = array()) { + public function alert($message, array $context = []) { $this->log(\OCP\Util::ERROR, $message, $context); } @@ -80,7 +80,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function critical($message, array $context = array()) { + public function critical($message, array $context = []) { $this->log(\OCP\Util::ERROR, $message, $context); } @@ -93,7 +93,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function error($message, array $context = array()) { + public function error($message, array $context = []) { $this->log(\OCP\Util::ERROR, $message, $context); } @@ -105,7 +105,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function warning($message, array $context = array()) { + public function warning($message, array $context = []) { $this->log(\OCP\Util::WARN, $message, $context); } @@ -117,7 +117,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function notice($message, array $context = array()) { + public function notice($message, array $context = []) { $this->log(\OCP\Util::INFO, $message, $context); } @@ -129,7 +129,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function info($message, array $context = array()) { + public function info($message, array $context = []) { $this->log(\OCP\Util::INFO, $message, $context); } @@ -141,7 +141,7 @@ class SmarterLogger implements ILogger { * * @return null */ - public function debug($message, array $context = array()) { + public function debug($message, array $context = []) { $this->log(\OCP\Util::DEBUG, $message, $context); } @@ -155,7 +155,7 @@ class SmarterLogger implements ILogger { * * @return mixed */ - public function log($level, $message, array $context = array()) { + public function log($level, $message, array $context = []) { array_walk($context, [$this, 'contextNormalizer']); if (!isset($context['app'])) { -- cgit v1.2.3