Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 8.4 explicit nullable compatibility #300

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading