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

Prepare for PHP 8.4 #572

Merged
merged 1 commit into from
Jul 20, 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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand All @@ -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)
Expand All @@ -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();

Expand All @@ -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)
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/RepositoryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Store/File/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function __construct()
*
* @return array<string,string>
*/
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 = [];

Expand All @@ -67,7 +67,7 @@ public static function read(array $filePaths, bool $shortCircuit = true, string
*
* @return \PhpOption\Option<string>
*/
private static function readFromFile(string $path, string $encoding = null)
private static function readFromFile(string $path, ?string $encoding = null)
{
/** @var Option<string> */
$content = Option::fromValue(@\file_get_contents($path), false);
Expand Down
2 changes: 1 addition & 1 deletion src/Store/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Store/StoreBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function occurrences(string $pattern, string $subject)
*
* @return \GrahamCampbell\ResultType\Result<string,string>
*/
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);
Expand Down
4 changes: 2 additions & 2 deletions src/Util/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private function __construct()
*
* @return \GrahamCampbell\ResultType\Result<string,string>
*/
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<string,string> */
Expand Down Expand Up @@ -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');
}
Expand Down
Loading