diff --git a/CHANGELOG.md b/CHANGELOG.md index a1e2607a..903b8001 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ All Notable changes to `Csv` will be documented in this file +## Next - TBD + +### Added + +- Nothing + +### Deprecated + +- Nothing + +### Fixed + +- `Writer::insertOne` allow empty array to be added to the CSV (allow inserting empty row) +- Removed all return type from named constructor see [#285](https://github.com/thephpleague/csv/pull/285) +- Added PHPStan for static code analysis + +### Removed + +- Nothing + ## 9.1.2 - 2018-02-05 ### Added diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index b2594b82..5adaf6e8 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/ByteSequence.php b/src/ByteSequence.php index 695f3acf..62012c09 100644 --- a/src/ByteSequence.php +++ b/src/ByteSequence.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/CannotInsertRecord.php b/src/CannotInsertRecord.php index a85922fd..8aa14cd9 100644 --- a/src/CannotInsertRecord.php +++ b/src/CannotInsertRecord.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/CharsetConverter.php b/src/CharsetConverter.php index f0ae33c2..671839fd 100644 --- a/src/CharsetConverter.php +++ b/src/CharsetConverter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE @@ -176,7 +176,7 @@ public function filter($in, $out, &$consumed, $closing) */ public function convert($records) { - if (!is_iterable($records)) { + if (!\is_iterable($records)) { throw new TypeError(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($records))); } diff --git a/src/ColumnConsistency.php b/src/ColumnConsistency.php index 86af082e..a03b3c0a 100644 --- a/src/ColumnConsistency.php +++ b/src/ColumnConsistency.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/EncloseField.php b/src/EncloseField.php index f5f69217..461be8d1 100644 --- a/src/EncloseField.php +++ b/src/EncloseField.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/EscapeFormula.php b/src/EscapeFormula.php index 714de111..bff9436d 100644 --- a/src/EscapeFormula.php +++ b/src/EscapeFormula.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Exception.php b/src/Exception.php index 1eeb75f7..2c283c18 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/HTMLConverter.php b/src/HTMLConverter.php index 687dc113..b1fa7224 100644 --- a/src/HTMLConverter.php +++ b/src/HTMLConverter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/MapIterator.php b/src/MapIterator.php index c4504fe2..83d0271d 100644 --- a/src/MapIterator.php +++ b/src/MapIterator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/RFC4180Field.php b/src/RFC4180Field.php index 62229dde..e7581b3e 100644 --- a/src/RFC4180Field.php +++ b/src/RFC4180Field.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Reader.php b/src/Reader.php index 727520c5..15726731 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/ResultSet.php b/src/ResultSet.php index 679048d1..7f507d6c 100644 --- a/src/ResultSet.php +++ b/src/ResultSet.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Statement.php b/src/Statement.php index 0b1aa40c..4441ffe4 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Stream.php b/src/Stream.php index 20338a2e..dae1ae68 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE @@ -297,7 +297,7 @@ public function setFlags(int $flags) * @param string $enclosure * @param string $escape * - * @return int|bool + * @return int|null|bool */ public function fputcsv(array $fields, string $delimiter = ',', string $enclosure = '"', string $escape = '\\') { diff --git a/src/Writer.php b/src/Writer.php index 9d0fa832..645a0876 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE @@ -97,7 +97,7 @@ public function getFlushThreshold() */ public function insertAll($records): int { - if (!is_iterable($records)) { + if (!\is_iterable($records)) { throw new TypeError(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($records))); } @@ -129,7 +129,7 @@ public function insertOne(array $record): int $record = array_reduce($this->formatters, [$this, 'formatRecord'], $record); $this->validateRecord($record); $bytes = $this->document->fputcsv($record, $this->delimiter, $this->enclosure, $this->escape); - if (false !== $bytes) { + if (false !== $bytes && null !== $bytes) { return $bytes + $this->consolidate(); } diff --git a/src/XMLConverter.php b/src/XMLConverter.php index 76363c6b..77c63f3c 100644 --- a/src/XMLConverter.php +++ b/src/XMLConverter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE @@ -90,7 +90,7 @@ class XMLConverter */ public function convert($records): DOMDocument { - if (!is_iterable($records)) { + if (!\is_iterable($records)) { throw new TypeError(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($records))); } diff --git a/src/functions.php b/src/functions.php index 63a6d7b1..40f936e0 100644 --- a/src/functions.php +++ b/src/functions.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.1.2 +* @version 9.1.3 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/tests/CsvTest.php b/tests/CsvTest.php index a85f4070..9e72c687 100644 --- a/tests/CsvTest.php +++ b/tests/CsvTest.php @@ -7,7 +7,6 @@ use League\Csv\Writer; use PHPUnit\Framework\TestCase; use SplTempFileObject; -use TypeError; /** * @group csv @@ -66,16 +65,6 @@ public function testCreateFromPathThrowsRuntimeException() Reader::createFromPath(__DIR__.'/foo/bar', 'r'); } - /** - * @covers ::createFromStream - */ - public function testCreateFromStreamWithInvalidParameter() - { - $this->expectException(TypeError::class); - $path = __DIR__.'/data/foo.csv'; - Reader::createFromStream($path); - } - /** * @covers ::getInputBOM * @@ -384,13 +373,13 @@ public function testIsIterablePolyFill() $this->markTestSkipped('Polyfill for PHP7.0'); } - $this->assertTrue(\is_iterable(['foo'])); - $this->assertTrue(\is_iterable(Reader::createFromString(''))); - $this->assertTrue(\is_iterable((function () { + $this->assertTrue(is_iterable(['foo'])); + $this->assertTrue(is_iterable(Reader::createFromString(''))); + $this->assertTrue(is_iterable((function () { yield 1; })())); - $this->assertFalse(\is_iterable(1)); - $this->assertFalse(\is_iterable((object) ['foo'])); - $this->assertFalse(\is_iterable(Writer::createFromString(''))); + $this->assertFalse(is_iterable(1)); + $this->assertFalse(is_iterable((object) ['foo'])); + $this->assertFalse(is_iterable(Writer::createFromString(''))); } }