diff --git a/src/FlattenException.php b/src/FlattenException.php index 0a7724be7..cf2ff0404 100644 --- a/src/FlattenException.php +++ b/src/FlattenException.php @@ -15,41 +15,41 @@ * Basically, this class removes all objects from the trace. * Ported from Symfony components @link https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/Exception/FlattenException.php */ -class FlattenException +final class FlattenException { /** * @var string */ - protected string $message; + private string $message; /** * @var int|mixed */ - protected $code; + private $code; /** * @var string */ - protected string $file; + private string $file; /** * @var int */ - protected int $line; + private int $line; /** * @var FlattenException|null */ - private ?FlattenException $_previous; + private ?FlattenException $previous; /** * @var array */ - private array $_trace; + private array $trace; /** * @var string */ - private string $_toString; + private string $toString; /** * @var string */ - private string $_class; + private string $class; /** * FlattenException constructor. @@ -75,9 +75,9 @@ public function __construct(Throwable $exception) /** * @param string $string the string representation of the thrown object. */ - protected function setToString($string): void + private function setToString(string $string): void { - $this->_toString = $string; + $this->toString = $string; } /** @@ -93,7 +93,7 @@ public function getMessage(): string /** * @param string $message the Exception message as a string. */ - protected function setMessage($message): void + private function setMessage(string $message): void { $this->message = $message; } @@ -111,7 +111,7 @@ public function getCode() /** * @param int|mixed $code the exception code as integer. */ - protected function setCode($code): void + private function setCode($code): void { $this->code = $code; } @@ -129,7 +129,7 @@ public function getFile(): string /** * @param string $file the filename in which the exception was created. */ - protected function setFile($file): void + private function setFile(string $file): void { $this->file = $file; } @@ -147,7 +147,7 @@ public function getLine(): int /** * @param int $line the line number where the exception was created. */ - protected function setLine($line): void + private function setLine(int $line): void { $this->line = $line; } @@ -159,15 +159,15 @@ protected function setLine($line): void */ public function getTrace(): array { - return $this->_trace; + return $this->trace; } /** * @param array $trace the Exception stack trace as an array. */ - protected function setTrace($trace): void + private function setTrace(array $trace): void { - $this->_trace = []; + $this->trace = []; foreach ($trace as $entry) { $class = ''; $namespace = ''; @@ -177,7 +177,7 @@ protected function setTrace($trace): void $namespace = implode('\\', $parts); } - $this->_trace[] = [ + $this->trace[] = [ 'namespace' => $namespace, 'short_class' => $class, 'class' => $entry['class'] ?? '', @@ -197,15 +197,15 @@ protected function setTrace($trace): void */ public function getPrevious(): ?self { - return $this->_previous; + return $this->previous; } /** * @param FlattenException $previous previous Exception. */ - protected function setPrevious(self $previous): void + private function setPrevious(self $previous): void { - $this->_previous = $previous; + $this->previous = $previous; } /** @@ -216,11 +216,11 @@ protected function setPrevious(self $previous): void public function getTraceAsString(): string { $remove = "Stack trace:\n"; - $len = strpos($this->_toString, $remove); + $len = strpos($this->toString, $remove); if ($len === false) { return ''; } - return substr($this->_toString, $len + strlen($remove)); + return substr($this->toString, $len + strlen($remove)); } /** @@ -230,7 +230,7 @@ public function getTraceAsString(): string */ public function __toString() { - return $this->_toString; + return $this->toString; } /** @@ -238,15 +238,15 @@ public function __toString() */ public function getClass(): string { - return $this->_class; + return $this->class; } /** * @param string $class the name of the class in which the exception was created. */ - protected function setClass($class): void + private function setClass(string $class): void { - $this->_class = $class; + $this->class = $class; } /** @@ -258,7 +258,7 @@ protected function setClass($class): void * * @return array arguments tracing. */ - private function flattenArgs($args, $level = 0, &$count = 0): array + private function flattenArgs(array $args, $level = 0, &$count = 0): array { $result = []; foreach ($args as $key => $value) {