From 652c59e5c259f1d94893e12ac499c29c046ad38f Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Sat, 3 Mar 2018 16:12:53 +0200 Subject: [PATCH 1/3] Ignore .php_cs.cache --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 039afea6..a73932c0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build composer.lock docs/_site vendor -/nbproject/private/ \ No newline at end of file +/nbproject/private/ +.php_cs.cache From 8b3063b3063b09b25e84893b06126e76d8163ba5 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Sat, 3 Mar 2018 16:13:53 +0200 Subject: [PATCH 2/3] Remove static return type-hint from createFromPath() The type-hint says "@return static", which means if you call Reader::createFromPath() it should return a Reader, not an AbstractCsv. Without this you can't use any of the methods provided by Reader without getting warnings during static analysis. --- src/AbstractCsv.php | 2 +- src/Reader.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 101dcbe1..97de078b 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -155,7 +155,7 @@ public static function createFromString(string $content): self * * @return static */ - public static function createFromPath(string $path, string $open_mode = 'r+', $context = null): self + public static function createFromPath(string $path, string $open_mode = 'r+', $context = null) { return new static(Stream::createFromPath($path, $open_mode, $context)); } diff --git a/src/Reader.php b/src/Reader.php index 087ce90a..727520c5 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -64,7 +64,7 @@ class Reader extends AbstractCsv implements Countable, IteratorAggregate, JsonSe /** * {@inheritdoc} */ - public static function createFromPath(string $path, string $open_mode = 'r', $context = null): AbstractCsv + public static function createFromPath(string $path, string $open_mode = 'r', $context = null) { return new static(Stream::createFromPath($path, $open_mode, $context)); } From 3cc811d1b106c14f64249804c9cb0a1d91c1d3c5 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Mon, 5 Mar 2018 12:46:22 +0200 Subject: [PATCH 3/3] Remove static return type-hints from other "createFrom" methods too --- src/AbstractCsv.php | 6 +++--- src/Stream.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 97de078b..b2594b82 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -117,7 +117,7 @@ public function __clone() * * @return static */ - public static function createFromFileObject(SplFileObject $file): self + public static function createFromFileObject(SplFileObject $file) { return new static($file); } @@ -129,7 +129,7 @@ public static function createFromFileObject(SplFileObject $file): self * * @return static */ - public static function createFromStream($stream): self + public static function createFromStream($stream) { return new static(new Stream($stream)); } @@ -141,7 +141,7 @@ public static function createFromStream($stream): self * * @return static */ - public static function createFromString(string $content): self + public static function createFromString(string $content) { return new static(Stream::createFromString($content)); } diff --git a/src/Stream.php b/src/Stream.php index ec4968d9..20338a2e 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -167,7 +167,7 @@ public function __debugInfo() * * @return static */ - public static function createFromPath(string $path, string $open_mode = 'r', $context = null): self + public static function createFromPath(string $path, string $open_mode = 'r', $context = null) { $args = [$path, $open_mode]; if (null !== $context) { @@ -192,7 +192,7 @@ public static function createFromPath(string $path, string $open_mode = 'r', $co * * @return static */ - public static function createFromString(string $content): self + public static function createFromString(string $content) { $resource = fopen('php://temp', 'r+'); fwrite($resource, $content);