Skip to content

Commit

Permalink
Reverted fix for implicitly nullable parameter declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
JanSlabon committed Jan 31, 2025
1 parent 5702b49 commit 146cb0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/GraphicsState.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ class GraphicsState
/**
* @param Matrix|null $ctm
*/
public function __construct($ctm = null)
public function __construct(?Matrix $ctm = null)
{
if ($ctm === null) {
$ctm = new Matrix();
} elseif (!($ctm instanceof Matrix)) {
throw new \InvalidArgumentException('$ctm must be an instance of Fpdi\\Matrix or null');
}

$this->ctm = $ctm;
Expand Down
9 changes: 2 additions & 7 deletions src/PdfParser/Type/PdfDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,15 @@ public static function create(array $entries = [])
* @return PdfNull|PdfType
* @throws PdfTypeException
*/
public static function get($dictionary, $key, $default = null)
public static function get($dictionary, $key, ?PdfType $default = null)
{
if ($default !== null && !($default instanceof PdfType)) {
throw new \InvalidArgumentException('Default value must be an instance of PdfType or null');
}
$dictionary = self::ensure($dictionary);

if (isset($dictionary->value[$key])) {
return $dictionary->value[$key];
}

return $default === null
? new PdfNull()
: $default;
return $default ?? new PdfNull();
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/PdfParser/Type/PdfStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ class PdfStream extends PdfType
* @return self
* @throws PdfTypeException
*/
public static function parse(PdfDictionary $dictionary, StreamReader $reader, $parser = null)
public static function parse(PdfDictionary $dictionary, StreamReader $reader, ?PdfParser $parser = null)
{
if ($parser !== null && !($parser instanceof PdfParser)) {
throw new \InvalidArgumentException('$parser must be an instance of PdfParser or null');
}
$v = new self();
$v->value = $dictionary;
$v->reader = $reader;
Expand Down

0 comments on commit 146cb0c

Please sign in to comment.