Skip to content

Commit 53e3430

Browse files
committed
CS Fix
1 parent c5b4fdc commit 53e3430

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

.php_cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$config = new SlamCsFixer\Config();
3+
$config = new SlamCsFixer\Config(SlamCsFixer\Config::LIB);
44
$config->getFinder()
55
->in(__DIR__ . '/lib')
66
->in(__DIR__ . '/tests')

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"require-dev": {
1717
"phpunit/phpunit": "^6.5",
1818
"roave/security-advisories": "dev-master",
19-
"slam/php-cs-fixer-extensions": "^1.10",
20-
"slam/php-debug-r": "^1.1",
19+
"slam/php-cs-fixer-extensions": "^1.12",
20+
"slam/php-debug-r": "^1.2",
2121
"symfony/console": "^4.0"
2222
},
2323
"autoload": {

lib/ErrorHandler.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ final class ErrorHandler
1616
private $logErrors;
1717
private $logVariables = true;
1818
private $emailCallback;
19-
private $scream = array();
19+
private $scream = [];
2020

21-
private static $colors = array(
21+
private static $colors = [
2222
'<error>' => "\033[37;41m",
2323
'</error>' => "\033[0m",
24-
);
24+
];
2525

26-
private static $errors = array(
26+
private static $errors = [
2727
\E_COMPILE_ERROR => 'E_COMPILE_ERROR',
2828
\E_COMPILE_WARNING => 'E_COMPILE_WARNING',
2929
\E_CORE_ERROR => 'E_CORE_ERROR',
@@ -39,7 +39,7 @@ final class ErrorHandler
3939
\E_USER_NOTICE => 'E_USER_NOTICE',
4040
\E_USER_WARNING => 'E_USER_WARNING',
4141
\E_WARNING => 'E_WARNING',
42-
);
42+
];
4343

4444
public function __construct(callable $emailCallback)
4545
{
@@ -145,8 +145,8 @@ public function getScreamSilencedErrors(): array
145145

146146
public function register(): void
147147
{
148-
\set_error_handler(array($this, 'errorHandler'), \error_reporting());
149-
\set_exception_handler(array($this, 'exceptionHandler'));
148+
\set_error_handler([$this, 'errorHandler'], \error_reporting());
149+
\set_exception_handler([$this, 'exceptionHandler']);
150150
}
151151

152152
public function errorHandler($errno, $errstr = '', $errfile = '', $errline = 0): void
@@ -168,13 +168,13 @@ public function exceptionHandler(\Throwable $exception): void
168168
$currentEx = $exception;
169169
do {
170170
$width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 3 : 120;
171-
$lines = array(
171+
$lines = [
172172
'Message: ' . $currentEx->getMessage(),
173173
'',
174174
'Class: ' . \get_class($currentEx),
175175
'Code: ' . $this->getExceptionCode($currentEx),
176176
'File: ' . $currentEx->getFile() . ':' . $currentEx->getLine(),
177-
);
177+
];
178178
$lines = \array_merge($lines, \explode(\PHP_EOL, $this->purgeTrace($currentEx->getTraceAsString())));
179179

180180
$i = 0;
@@ -286,18 +286,18 @@ public function emailException(\Throwable $exception): void
286286
return;
287287
}
288288

289-
$bodyArray = array(
289+
$bodyArray = [
290290
'Data' => \date(\DATE_RFC850),
291291
'REQUEST_URI' => $_SERVER['REQUEST_URI'] ?? '',
292292
'HTTP_REFERER' => $_SERVER['HTTP_REFERER'] ?? '',
293293
'USER_AGENT' => $_SERVER['HTTP_USER_AGENT'] ?? '',
294294
'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'] ?? '',
295-
);
295+
];
296296
if ($this->isCli()) {
297-
$bodyArray = array(
297+
$bodyArray = [
298298
'Data' => \date(\DATE_RFC850),
299299
'Comando' => \sprintf('$ php %s', \implode(' ', $_SERVER['argv'])),
300-
);
300+
];
301301
}
302302

303303
$bodyText = '';
@@ -307,12 +307,12 @@ public function emailException(\Throwable $exception): void
307307

308308
$currentEx = $exception;
309309
do {
310-
$bodyArray = array(
310+
$bodyArray = [
311311
'Class' => \get_class($currentEx),
312312
'Code' => $this->getExceptionCode($currentEx),
313313
'Message' => $currentEx->getMessage(),
314314
'File' => $currentEx->getFile() . ':' . $currentEx->getLine(),
315-
);
315+
];
316316

317317
foreach ($bodyArray as $key => $val) {
318318
$bodyText .= \sprintf('%-15s%s%s', $key, $val, \PHP_EOL);

tests/ErrorHandlerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ protected function setUp()
2323
\ini_set('error_log', $this->errorLog);
2424

2525
$this->exception = new ErrorException(\uniqid('normal_'), \E_USER_NOTICE);
26-
$this->emailsSent = array();
26+
$this->emailsSent = [];
2727
$this->errorHandler = new ErrorHandler(function ($subject, $body) {
28-
$this->emailsSent[] = array(
28+
$this->emailsSent[] = [
2929
'subject' => $subject,
3030
'body' => $body,
31-
);
31+
];
3232
});
3333

3434
$this->errorHandler->setAutoExit(false);
@@ -76,7 +76,7 @@ public function testDefaultConfiguration()
7676
public function testRegisterBuiltinHandlers()
7777
{
7878
$this->errorHandler->register();
79-
$arrayPerVerificaErrori = array();
79+
$arrayPerVerificaErrori = [];
8080

8181
@ $arrayPerVerificaErrori['no_exception_thrown_on_undefined_index_now'];
8282

@@ -90,9 +90,9 @@ public function testRegisterBuiltinHandlers()
9090
*/
9191
public function testScream()
9292
{
93-
$scream = array(
93+
$scream = [
9494
\E_USER_WARNING => true,
95-
);
95+
];
9696

9797
$this->assertEmpty($this->errorHandler->getScreamSilencedErrors());
9898
$this->errorHandler->setScreamSilencedErrors($scream);
@@ -184,8 +184,8 @@ public function testEmailException()
184184
$this->errorHandler->setLogErrors(true);
185185

186186
$key = \uniqid(__FUNCTION__);
187-
$_SESSION = array($key => \uniqid());
188-
$_POST = array($key => \uniqid());
187+
$_SESSION = [$key => \uniqid()];
188+
$_POST = [$key => \uniqid()];
189189

190190
$this->errorHandler->emailException($this->exception);
191191

@@ -208,8 +208,8 @@ public function testCanHideVariablesFromEmail()
208208
$this->errorHandler->setLogErrors(true);
209209

210210
$key = \uniqid(__FUNCTION__);
211-
$_SESSION = array($key => \uniqid());
212-
$_POST = array($key => \uniqid());
211+
$_SESSION = [$key => \uniqid()];
212+
$_POST = [$key => \uniqid()];
213213

214214
$this->errorHandler->emailException($this->exception);
215215

@@ -242,7 +242,7 @@ public function testErroriNellInvioDellaMailVengonoComunqueLoggati()
242242
public function testUsernameInEmailSubject()
243243
{
244244
$username = \uniqid('bob_');
245-
$_SESSION = array('custom_username_key' => $username);
245+
$_SESSION = ['custom_username_key' => $username];
246246

247247
$this->errorHandler->setLogErrors(true);
248248
$this->errorHandler->emailException($this->exception);

0 commit comments

Comments
 (0)