Skip to content

Commit ab80b3d

Browse files
committed
Rename exception args; add types
1 parent f1fda3d commit ab80b3d

File tree

2 files changed

+13
-28
lines changed

2 files changed

+13
-28
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
1111
- `$source` is now `$json`
1212
- `$options` is now `$flags`
1313
- Added explicit `mixed` return type to match `json_decode()`
14+
- Added proper types to all parameters and return values of `SyntaxError`
15+
- Renamed two arguments in the `SyntaxError`'s constructor:
16+
- `$linenumber` is now `$lineNumber`
17+
- `$columnNumber` is now `$column`
1418

1519
### Removed
1620
- Removed support for PHP 7.x (8.0+ is now required)

src/SyntaxError.php

+9-28
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,23 @@
1616

1717
final class SyntaxError extends \JsonException
1818
{
19-
/** @var int */
20-
private $lineNumber;
21-
22-
/** @var int */
23-
private $column;
24-
25-
/**
26-
* SyntaxError constructor.
27-
*
28-
* @param string $message
29-
* @param int $linenumber
30-
* @param int $columnNumber
31-
* @param \Throwable|null $previous
32-
*/
33-
public function __construct($message, $linenumber, $columnNumber, $previous = null)
34-
{
35-
$message = \sprintf('%s at line %d column %d of the JSON5 data', $message, $linenumber, $columnNumber);
19+
public function __construct(
20+
string $message,
21+
private int $lineNumber,
22+
private int $column,
23+
\Throwable|null $previous = null
24+
) {
25+
$message = \sprintf('%s at line %d column %d of the JSON5 data', $message, $lineNumber, $column);
3626

3727
parent::__construct($message, 0, $previous);
38-
39-
$this->lineNumber = $linenumber;
40-
$this->column = $columnNumber;
4128
}
4229

43-
/**
44-
* @return int
45-
*/
46-
public function getLineNumber()
30+
public function getLineNumber(): int
4731
{
4832
return $this->lineNumber;
4933
}
5034

51-
/**
52-
* @return int
53-
*/
54-
public function getColumn()
35+
public function getColumn(): int
5536
{
5637
return $this->column;
5738
}

0 commit comments

Comments
 (0)