Skip to content

Commit 54288aa

Browse files
authored
Merge pull request #9 from tvdijen/master
Fix PHP 8.4 deprecation notices
2 parents a4fa5ed + fb0c9fc commit 54288aa

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

.github/workflows/test.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,22 @@ jobs:
1919
- 7.4
2020
- 8.0
2121
- 8.1
22+
- 8.2
23+
- 8.3
24+
- 8.4
2225
fail-fast: false
2326

2427
steps:
2528
- name: Checkout
26-
uses: actions/checkout@v2
29+
uses: actions/checkout@v4
2730

2831
- name: Install PHP
2932
uses: shivammathur/setup-php@v2
3033
with:
3134
php-version: ${{ matrix.php }}
3235

3336
- name: Cache PHP dependencies
34-
uses: actions/cache@v2
37+
uses: actions/cache@v4
3538
with:
3639
path: vendor
3740
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
@@ -41,4 +44,4 @@ jobs:
4144
run: composer install --prefer-dist --no-progress --no-suggest
4245

4346
- name: Tests
44-
run: composer test
47+
run: composer test

src/GettextTranslator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class GettextTranslator implements TranslatorInterface
1010
/**
1111
* Detects the current language using the environment variables.
1212
*/
13-
public function __construct(string $language = null)
13+
public function __construct(?string $language = null)
1414
{
1515
if (!function_exists('gettext')) {
1616
throw new RuntimeException('This class require the gettext extension for PHP');
@@ -30,7 +30,7 @@ public function __construct(string $language = null)
3030
/**
3131
* Define the current locale.
3232
*/
33-
public function setLanguage(string $language, int $category = null): self
33+
public function setLanguage(string $language, ?int $category = null): self
3434
{
3535
if ($category === null) {
3636
$category = defined('LC_MESSAGES') ? LC_MESSAGES : LC_ALL;
@@ -45,7 +45,7 @@ public function setLanguage(string $language, int $category = null): self
4545
/**
4646
* Loads a gettext domain.
4747
*/
48-
public function loadDomain(string $domain, string $path = null, bool $default = true): self
48+
public function loadDomain(string $domain, ?string $path = null, bool $default = true): self
4949
{
5050
bindtextdomain($domain, $path);
5151
bind_textdomain_codeset($domain, 'UTF-8');

src/Loader/ArrayLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
*/
1313
final class ArrayLoader extends Loader
1414
{
15-
public function loadFile(string $filename, Translations $translations = null): Translations
15+
public function loadFile(string $filename, ?Translations $translations = null): Translations
1616
{
1717
$array = self::includeSafe($filename);
1818

1919
return $this->loadArray($array, $translations);
2020
}
2121

22-
public function loadString(string $string, Translations $translations = null): Translations
22+
public function loadString(string $string, ?Translations $translations = null): Translations
2323
{
2424
throw new BadMethodCallException('Arrays cannot be loaded from string. Use ArrayLoader::loadFile() instead');
2525
}
@@ -29,7 +29,7 @@ private static function includeSafe($filename): array
2929
return include $filename;
3030
}
3131

32-
public function loadArray(array $array, Translations $translations = null): Translations
32+
public function loadArray(array $array, ?Translations $translations = null): Translations
3333
{
3434
if (!$translations) {
3535
$translations = $this->createTranslations();

src/TranslatorFunctions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ abstract class TranslatorFunctions
88
private static $translator;
99
private static $formatter;
1010

11-
public static function register(TranslatorInterface $translator, FormatterInterface $formatter = null): void
11+
public static function register(TranslatorInterface $translator, ?FormatterInterface $formatter = null): void
1212
{
1313
self::$translator = $translator;
1414
self::$formatter = $formatter ?: new Formatter();

0 commit comments

Comments
 (0)