@@ -45,8 +45,7 @@ public function __construct(
4545 /**
4646 * Building request url
4747 *
48- * @return string url
49- *
48+ * @return string|null url
5049 */
5150 private function buildRequestUrl (): ?string
5251 {
@@ -72,11 +71,13 @@ private function guessProtocol(): string
7271 {
7372 if (!empty ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ])) {
7473 return $ _SERVER ['HTTP_X_FORWARDED_PROTO ' ];
75- } elseif (!empty ($ _SERVER ['SERVER_PORT ' ]) && $ _SERVER ['SERVER_PORT ' ] == 443 ) {
74+ }
75+
76+ if (!empty ($ _SERVER ['SERVER_PORT ' ]) && $ _SERVER ['SERVER_PORT ' ] === 443 ) {
7677 return 'https ' ;
77- } else {
78- return 'http ' ;
7978 }
79+
80+ return 'http ' ;
8081 }
8182
8283 /**
@@ -88,11 +89,13 @@ private function guessHost(): string
8889 {
8990 if (!empty ($ _SERVER ['HTTP_HOST ' ])) {
9091 return $ _SERVER ['HTTP_HOST ' ];
91- } elseif (!empty ($ _SERVER ['SERVER_NAME ' ])) {
92+ }
93+
94+ if (!empty ($ _SERVER ['SERVER_NAME ' ])) {
9295 return $ _SERVER ['SERVER_NAME ' ];
93- } else {
94- return '127.0.0.1 ' ;
9596 }
97+
98+ return '127.0.0.1 ' ;
9699 }
97100
98101 /**
@@ -180,13 +183,12 @@ public function asXml(): string
180183 $ exception = $ this ->exception ;
181184 $ options = $ this ->options ;
182185 $ builder = new XmlBuilder ();
183- $ self = $ this ;
184-
186+
185187 return $ builder ->tag (
186188 'notice ' ,
187189 '' ,
188190 ['version ' => Errbit::API_VERSION ],
189- function (XmlBuilder $ notice ) use ($ exception , $ options, $ self ) {
191+ function (XmlBuilder $ notice ) use ($ exception , $ options ) {
190192 $ notice ->tag ('api-key ' , $ options ['api_key ' ]);
191193 $ notice ->tag (
192194 'notifier ' ,
@@ -203,7 +205,8 @@ function (XmlBuilder $notifier) {
203205 'error ' ,
204206 '' ,
205207 [],
206- function (XmlBuilder $ error ) use ($ exception , $ self ) {
208+ function (XmlBuilder $ error ) use ($ exception ) {
209+ $ self = $ this ;
207210 $ class = Notice::className ($ exception );
208211 $ error ->tag ('class ' , $ self ->filterTrace ($ class ));
209212 $ error ->tag (
@@ -374,7 +377,7 @@ function (XmlBuilder $env) use ($options) {
374377 }
375378
376379 /**
377- * Get a human readable class name for the Exception.
380+ * Get a human- readable class name for the Exception.
378381 *
379382 * Native PHP errors are named accordingly.
380383 *
@@ -385,18 +388,14 @@ function (XmlBuilder $env) use ($options) {
385388 public static function className (object $ exception ): string
386389 {
387390 $ shortClassname = self ::parseClassname ($ exception ::class);
388- switch ($ shortClassname ['classname ' ]) {
389- case 'Notice ' :
390- return 'Notice ' ;
391- case 'Warning ' :
392- return 'Warning ' ;
393- case 'Error ' :
394- return 'Error ' ;
395- case 'Fatal ' :
396- return 'Fatal Error ' ;
397- default :
398- return $ shortClassname ['classname ' ];
399- }
391+
392+ return match ($ shortClassname ['classname ' ]) {
393+ 'Notice ' => 'Notice ' ,
394+ 'Warning ' => 'Warning ' ,
395+ 'Error ' => 'Error ' ,
396+ 'Fatal ' => 'Fatal Error ' ,
397+ default => $ shortClassname ['classname ' ],
398+ };
400399 }
401400
402401 /**
@@ -455,16 +454,16 @@ public static function formatMethod(array $frame): string
455454 $ frame ['type ' ],
456455 $ frame ['function ' ]
457456 );
458- } else {
459- return sprintf (
460- '%s() ' ,
461- !empty ($ frame ['function ' ]) ? $ frame ['function ' ] : '<unknown> '
462- );
463457 }
458+
459+ return sprintf (
460+ '%s() ' ,
461+ !empty ($ frame ['function ' ]) ? $ frame ['function ' ] : '<unknown> '
462+ );
464463 }
465464
466465 /**
467- * Recursively build an list of the all the vars in the given array.
466+ * Recursively build a list of the all the vars in the given array.
468467 *
469468 * @param \Errbit\Utils\XmlBuilder $builder the builder instance to set the
470469 * data into
@@ -486,7 +485,7 @@ public static function xmlVarsFor(XmlBuilder $builder, array $array): void
486485 }
487486
488487 if (is_array ($ value )) {
489- if (null == $ hash || !in_array ($ hash , self ::$ hashArray )) {
488+ if (null === $ hash || !in_array ($ hash , self ::$ hashArray, true )) {
490489 self ::$ hashArray [] = $ hash ;
491490 $ builder ->tag (
492491 'var ' ,
@@ -506,7 +505,7 @@ function ($var) use ($value) {
506505 }
507506
508507 } else {
509- $ builder ->tag ('var ' , $ value , ['key ' => $ key ]);
508+ $ builder ->tag ('var ' , ( string ) $ value , ['key ' => $ key ]);
510509 }
511510 }
512511 }
0 commit comments