diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d08bd7..cf9699e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ 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 + convert the string to an integer. + ## [1.0.1] - 2025-01-22 diff --git a/src/LogLib2/Objects/ExceptionDetails.php b/src/LogLib2/Objects/ExceptionDetails.php index c78c22f..cdc7eb3 100644 --- a/src/LogLib2/Objects/ExceptionDetails.php +++ b/src/LogLib2/Objects/ExceptionDetails.php @@ -25,12 +25,17 @@ * @param string $message The exception message. * @param int|null $code The exception code, or null if not specified. * @param string|null $file The file name, or null if not specified. - * @param int|null $line The line number, 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, ?int $line=null, ?array $trace=null, ?ExceptionDetails $previous=null) + public function __construct(string $name, string $message, ?int $code=null, ?string $file=null, null|string|int $line=null, ?array $trace=null, ?ExceptionDetails $previous=null) { + if(is_string($line)) + { + $line = (int)$line; + } + $this->name = $name; $this->message = $message; $this->code = $code;