From d31de17d8994832de1ff233986b224c3b56ef475 Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Sat, 20 Jul 2024 23:26:17 +0200 Subject: [PATCH] Prepare for PHP 8.4 (#572) --- .github/workflows/tests.yml | 4 ++-- src/Dotenv.php | 12 ++++++------ src/Parser/Entry.php | 2 +- src/Repository/RepositoryBuilder.php | 4 ++-- src/Store/File/Reader.php | 4 ++-- src/Store/FileStore.php | 2 +- src/Store/StoreBuilder.php | 4 ++-- src/Util/Regex.php | 2 +- src/Util/Str.php | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f3e30e15..6e70b81c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout Code @@ -43,7 +43,7 @@ jobs: strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout Code diff --git a/src/Dotenv.php b/src/Dotenv.php index 0460ced2..6821c7d9 100644 --- a/src/Dotenv.php +++ b/src/Dotenv.php @@ -80,7 +80,7 @@ public function __construct( * * @return \Dotenv\Dotenv */ - public static function create(RepositoryInterface $repository, $paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function create(RepositoryInterface $repository, $paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $builder = $names === null ? StoreBuilder::createWithDefaultName() : StoreBuilder::createWithNoNames(); @@ -109,7 +109,7 @@ public static function create(RepositoryInterface $repository, $paths, $names = * * @return \Dotenv\Dotenv */ - public static function createMutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createMutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters()->make(); @@ -126,7 +126,7 @@ public static function createMutable($paths, $names = null, bool $shortCircuit = * * @return \Dotenv\Dotenv */ - public static function createUnsafeMutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createUnsafeMutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters() ->addAdapter(PutenvAdapter::class) @@ -145,7 +145,7 @@ public static function createUnsafeMutable($paths, $names = null, bool $shortCir * * @return \Dotenv\Dotenv */ - public static function createImmutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createImmutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters()->immutable()->make(); @@ -162,7 +162,7 @@ public static function createImmutable($paths, $names = null, bool $shortCircuit * * @return \Dotenv\Dotenv */ - public static function createUnsafeImmutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createUnsafeImmutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters() ->addAdapter(PutenvAdapter::class) @@ -182,7 +182,7 @@ public static function createUnsafeImmutable($paths, $names = null, bool $shortC * * @return \Dotenv\Dotenv */ - public static function createArrayBacked($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createArrayBacked($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithNoAdapters()->addAdapter(ArrayAdapter::class)->make(); diff --git a/src/Parser/Entry.php b/src/Parser/Entry.php index 7570f587..716f422e 100644 --- a/src/Parser/Entry.php +++ b/src/Parser/Entry.php @@ -30,7 +30,7 @@ final class Entry * * @return void */ - public function __construct(string $name, Value $value = null) + public function __construct(string $name, ?Value $value = null) { $this->name = $name; $this->value = $value; diff --git a/src/Repository/RepositoryBuilder.php b/src/Repository/RepositoryBuilder.php index a042f9a1..76079244 100644 --- a/src/Repository/RepositoryBuilder.php +++ b/src/Repository/RepositoryBuilder.php @@ -65,7 +65,7 @@ final class RepositoryBuilder * * @return void */ - private function __construct(array $readers = [], array $writers = [], bool $immutable = false, array $allowList = null) + private function __construct(array $readers = [], array $writers = [], bool $immutable = false, ?array $allowList = null) { $this->readers = $readers; $this->writers = $writers; @@ -244,7 +244,7 @@ public function immutable() * * @return \Dotenv\Repository\RepositoryBuilder */ - public function allowList(array $allowList = null) + public function allowList(?array $allowList = null) { return new self($this->readers, $this->writers, $this->immutable, $allowList); } diff --git a/src/Store/File/Reader.php b/src/Store/File/Reader.php index bcbbf7ad..b0b7c5b4 100644 --- a/src/Store/File/Reader.php +++ b/src/Store/File/Reader.php @@ -40,7 +40,7 @@ private function __construct() * * @return array */ - public static function read(array $filePaths, bool $shortCircuit = true, string $fileEncoding = null) + public static function read(array $filePaths, bool $shortCircuit = true, ?string $fileEncoding = null) { $output = []; @@ -67,7 +67,7 @@ public static function read(array $filePaths, bool $shortCircuit = true, string * * @return \PhpOption\Option */ - private static function readFromFile(string $path, string $encoding = null) + private static function readFromFile(string $path, ?string $encoding = null) { /** @var Option */ $content = Option::fromValue(@\file_get_contents($path), false); diff --git a/src/Store/FileStore.php b/src/Store/FileStore.php index 43f6135c..e7a4d3f1 100644 --- a/src/Store/FileStore.php +++ b/src/Store/FileStore.php @@ -39,7 +39,7 @@ final class FileStore implements StoreInterface * * @return void */ - public function __construct(array $filePaths, bool $shortCircuit, string $fileEncoding = null) + public function __construct(array $filePaths, bool $shortCircuit, ?string $fileEncoding = null) { $this->filePaths = $filePaths; $this->shortCircuit = $shortCircuit; diff --git a/src/Store/StoreBuilder.php b/src/Store/StoreBuilder.php index 304117fc..2ce08515 100644 --- a/src/Store/StoreBuilder.php +++ b/src/Store/StoreBuilder.php @@ -51,7 +51,7 @@ final class StoreBuilder * * @return void */ - private function __construct(array $paths = [], array $names = [], bool $shortCircuit = false, string $fileEncoding = null) + private function __construct(array $paths = [], array $names = [], bool $shortCircuit = false, ?string $fileEncoding = null) { $this->paths = $paths; $this->names = $names; @@ -120,7 +120,7 @@ public function shortCircuit() * * @return \Dotenv\Store\StoreBuilder */ - public function fileEncoding(string $fileEncoding = null) + public function fileEncoding(?string $fileEncoding = null) { return new self($this->paths, $this->names, $this->shortCircuit, $fileEncoding); } diff --git a/src/Util/Regex.php b/src/Util/Regex.php index 52c15780..b17355c6 100644 --- a/src/Util/Regex.php +++ b/src/Util/Regex.php @@ -64,7 +64,7 @@ public static function occurrences(string $pattern, string $subject) * * @return \GrahamCampbell\ResultType\Result */ - public static function replaceCallback(string $pattern, callable $callback, string $subject, int $limit = null) + public static function replaceCallback(string $pattern, callable $callback, string $subject, ?int $limit = null) { return self::pregAndWrap(static function (string $subject) use ($pattern, $callback, $limit) { return (string) @\preg_replace_callback($pattern, $callback, $subject, $limit ?? -1); diff --git a/src/Util/Str.php b/src/Util/Str.php index 087e236a..15257bdf 100644 --- a/src/Util/Str.php +++ b/src/Util/Str.php @@ -33,7 +33,7 @@ private function __construct() * * @return \GrahamCampbell\ResultType\Result */ - public static function utf8(string $input, string $encoding = null) + public static function utf8(string $input, ?string $encoding = null) { if ($encoding !== null && !\in_array($encoding, \mb_list_encodings(), true)) { /** @var \GrahamCampbell\ResultType\Result */ @@ -79,7 +79,7 @@ public static function pos(string $haystack, string $needle) * * @return string */ - public static function substr(string $input, int $start, int $length = null) + public static function substr(string $input, int $start, ?int $length = null) { return \mb_substr($input, $start, $length, 'UTF-8'); }