diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9699e..171e794 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Minor changes to the project ### Changed - - ExceptionDetails now accepts a string as a type for the $line parameter, this will automatically + - ExceptionDetails now accepts a string as a type for the $line and $code parameter, this will automatically convert the string to an integer. diff --git a/src/LogLib2/Objects/ExceptionDetails.php b/src/LogLib2/Objects/ExceptionDetails.php index cdc7eb3..3d9a2f3 100644 --- a/src/LogLib2/Objects/ExceptionDetails.php +++ b/src/LogLib2/Objects/ExceptionDetails.php @@ -23,19 +23,24 @@ * * @param string $name The name of the exception. * @param string $message The exception message. - * @param int|null $code The exception code, or null if not specified. + * @param string|int|null $code The exception code, or null if not specified. If a string is provided, it will be converted to an integer. * @param string|null $file The file name, or null if not specified. * @param string|int|null $line The line number, or null if not specified. If a string is provided, it will be converted to an integer. * @param StackTrace[]|null $trace The array of StackTrace instances, or null if not provided. * @param ExceptionDetails|null $previous The previous exception, or null if not specified. */ - public function __construct(string $name, string $message, ?int $code=null, ?string $file=null, null|string|int $line=null, ?array $trace=null, ?ExceptionDetails $previous=null) + public function __construct(string $name, string $message, null|string|int $code=null, ?string $file=null, null|string|int $line=null, ?array $trace=null, ?ExceptionDetails $previous=null) { if(is_string($line)) { $line = (int)$line; } + if(is_string($code)) + { + $code = (int)$code; + } + $this->name = $name; $this->message = $message; $this->code = $code;