diff --git a/src/SpreadCompat.php b/src/SpreadCompat.php index 7542af9..c2ee2d5 100644 --- a/src/SpreadCompat.php +++ b/src/SpreadCompat.php @@ -100,7 +100,7 @@ public static function getAdapterByName(string $ext, string $name): SpreadInterf return new ($class); } - public static function getAdapterForFile(string $filename, string $ext = null): SpreadInterface + public static function getAdapterForFile(string $filename, ?string $ext = null): SpreadInterface { if ($ext === null) { $ext = pathinfo($filename, PATHINFO_EXTENSION); @@ -350,10 +350,8 @@ protected static function getExtensionFromOpts(array $opts, ?string $fallback = return is_string($ext) ? $ext : null; } - public static function read( - string $filename, - ...$opts - ): Generator { + public static function read(string $filename, ...$opts): Generator + { $ext = self::getExtensionFromOpts($opts); $adapter = self::getAdapterFromOpts($opts, $ext); if (!$adapter) { @@ -362,11 +360,8 @@ public static function read( return $adapter->readFile($filename, ...$opts); } - public static function readString( - string $contents, - string $ext = null, - ...$opts - ): Generator { + public static function readString(string $contents, ?string $ext = null, ...$opts): Generator + { $ext = self::getExtensionFromOpts($opts, $ext); if ($ext === null) { $ext = self::getExtensionForContent($contents); @@ -378,11 +373,8 @@ public static function readString( return $adapter->readString($contents, ...$opts); } - public static function write( - iterable $data, - string $filename, - ...$opts - ): bool { + public static function write(iterable $data, string $filename, ...$opts): bool + { $ext = self::getExtensionFromOpts($opts); $adapter = self::getAdapterFromOpts($opts, $ext); if (!$adapter) { @@ -391,11 +383,8 @@ public static function write( return $adapter->writeFile($data, $filename, ...$opts); } - public static function writeString( - iterable $data, - string $ext = null, - ...$opts - ): string { + public static function writeString(iterable $data, ?string $ext = null, ...$opts): string + { $ext = self::getExtensionFromOpts($opts); $adapter = self::getAdapterFromOpts($opts, $ext); if (!$adapter && !$ext) {