Skip to content

Commit

Permalink
Fix PHP 8.4 explicit nullable compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cracksalad committed Oct 8, 2024
1 parent a9f89e0 commit dc5d398
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Loader/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
*/
abstract class Loader implements LoaderInterface
{
public function loadFile(string $filename, Translations $translations = null): Translations
public function loadFile(string $filename, ?Translations $translations = null): Translations
{
$string = static::readFile($filename);

return $this->loadString($string, $translations);
}

public function loadString(string $string, Translations $translations = null): Translations
public function loadString(string $string, ?Translations $translations = null): Translations
{
return $translations ?: $this->createTranslations();
}
Expand All @@ -29,7 +29,7 @@ protected function createTranslations(): Translations
return Translations::create();
}

protected function createTranslation(?string $context, string $original, string $plural = null): ?Translation
protected function createTranslation(?string $context, string $original, ?string $plural = null): ?Translation
{
$translation = Translation::create($context, $original);

Expand Down
4 changes: 2 additions & 2 deletions src/Loader/LoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

interface LoaderInterface
{
public function loadFile(string $filename, Translations $translations = null): Translations;
public function loadFile(string $filename, ?Translations $translations = null): Translations;

public function loadString(string $string, Translations $translations = null): Translations;
public function loadString(string $string, ?Translations $translations = null): Translations;
}
2 changes: 1 addition & 1 deletion src/Loader/MoLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class MoLoader extends Loader
private const MAGIC2 = -569244523;
private const MAGIC3 = 2500072158;

public function loadString(string $string, Translations $translations = null): Translations
public function loadString(string $string, ?Translations $translations = null): Translations
{
$translations = parent::loadString($string, $translations);
$this->init($string);
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/PoLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
final class PoLoader extends Loader
{
public function loadString(string $string, Translations $translations = null): Translations
public function loadString(string $string, ?Translations $translations = null): Translations
{
$translations = parent::loadString($string, $translations);

Expand Down
2 changes: 1 addition & 1 deletion src/Loader/StrictPoLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class StrictPoLoader extends Loader
/**
* Generates a Translations object from a .po based string
*/
public function loadString(string $data, Translations $translations = null): Translations
public function loadString(string $data, ?Translations $translations = null): Translations
{
$this->data = $data;
$this->position = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/References.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __debugInfo()
return $this->toArray();
}

public function add(string $filename, int $line = null): self
public function add(string $filename, ?int $line = null): self
{
$fileReferences = $this->references[$filename] ?? [];

Expand Down
2 changes: 1 addition & 1 deletion src/Scanner/ParsedFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class ParsedFunction
private $comments = [];
private $flags = [];

public function __construct(string $name, string $filename, int $line, int $lastLine = null)
public function __construct(string $name, string $filename, int $line, ?int $lastLine = null)
{
$this->name = $name;
$this->filename = $filename;
Expand Down
2 changes: 1 addition & 1 deletion src/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function translatePlural(string ...$translations): self
return $this;
}

public function getPluralTranslations(int $size = null): array
public function getPluralTranslations(?int $size = null): array
{
if ($size === null) {
return $this->pluralTranslations;
Expand Down
2 changes: 1 addition & 1 deletion src/Translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Translations implements Countable, IteratorAggregate
protected $headers;
protected $flags;

public static function create(string $domain = null, string $language = null): Translations
public static function create(?string $domain = null, ?string $language = null): Translations
{
$translations = new static();

Expand Down

0 comments on commit dc5d398

Please sign in to comment.