Skip to content

Commit

Permalink
Improve compatibility with PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Aug 1, 2022
1 parent d255835 commit 33c60a3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/ArrayFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ArrayFile implements DataFileInterface
/**
* Printer used to define output syntax
*/
protected ArrayPrinter|null $printer = null;
protected ?ArrayPrinter $printer = null;

/**
* Index of ast containing return stmt
Expand Down Expand Up @@ -74,8 +74,9 @@ final public function __construct(array $ast, Lexer $lexer, string $filePath = n
*
* @throws \InvalidArgumentException if the provided path doesn't exist and $throwIfMissing is true
* @throws ConfigWriterException if the provided path is unable to be parsed
* @return static
*/
public static function open(string $filePath, bool $throwIfMissing = false): static
public static function open(string $filePath, bool $throwIfMissing = false)
{
$exists = file_exists($filePath);

Expand Down Expand Up @@ -118,8 +119,12 @@ public static function open(string $filePath, bool $throwIfMissing = false): sta
* 'property.key2.value' => 'example'
* ]);
* ```
*
* @param string|array<string|int, mixed> $key
* @param mixed $value
* @return static
*/
public function set(string|array $key, $value = null): static
public function set($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $name => $value) {
Expand Down
7 changes: 5 additions & 2 deletions src/Contracts/DataFileInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ interface DataFileInterface
{
/**
* Return a new instance of `DataFileInterface` ready for modification of the provided filepath.
*
* @return static
*/
public static function open(string $filePath): static;
public static function open(string $filePath);

/**
* Set a property within the data.
*
* @param string|array<string|int, mixed> $key
* @param mixed $value
* @return static
*/
public function set(string|array $key, $value = null): static;
public function set($key, $value = null);

/**
* Write the current data to a file
Expand Down
9 changes: 7 additions & 2 deletions src/EnvFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ final public function __construct(string $filePath)

/**
* Return a new instance of `EnvFile` ready for modification of the file.
*
* @return static
*/
public static function open(string $filePath): static
public static function open(string $filePath)
{
return new static($filePath);
}
Expand All @@ -57,8 +59,11 @@ public static function open(string $filePath): static
* 'DIF_PROPERTY' => 'example'
* ]);
* ```
* @param string|array<string|int, mixed> $key
* @param mixed $value
* @return static
*/
public function set(array|string $key, $value = null): static
public function set($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $item => $value) {
Expand Down

0 comments on commit 33c60a3

Please sign in to comment.