ExceptionDetails now accepts a string as a type for the $line and $code parameter, this will automatically

convert the string to an integer.
This commit is contained in:
netkas 2025-01-27 03:21:02 -05:00
parent 61be8c6d73
commit 418353b579
2 changed files with 8 additions and 3 deletions

View file

@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Minor changes to the project Minor changes to the project
### Changed ### 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. convert the string to an integer.

View file

@ -23,19 +23,24 @@
* *
* @param string $name The name of the exception. * @param string $name The name of the exception.
* @param string $message The exception message. * @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|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 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 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. * @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)) if(is_string($line))
{ {
$line = (int)$line; $line = (int)$line;
} }
if(is_string($code))
{
$code = (int)$code;
}
$this->name = $name; $this->name = $name;
$this->message = $message; $this->message = $message;
$this->code = $code; $this->code = $code;