Permit CSV Delimiter to be Set to Null (#2288)
* Permit CSV Delimiter to be Set to Null See issue #2287. A 1-character change. The delimiter variable is defined as nullable, and getDelimiter can return null; setDelimiter should follow suit. * Scrutinizer Inanity Are you sure the test always returns null????? Yes, I'm sure, that's why it's part of the test. Let's see if we can recode it and miss this "problem".
This commit is contained in:
parent
4dd5c06c7b
commit
cc14a48604
|
|
@ -369,7 +369,7 @@ class Csv extends BaseReader
|
||||||
return $this->delimiter;
|
return $this->delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDelimiter(string $delimiter): self
|
public function setDelimiter(?string $delimiter): self
|
||||||
{
|
{
|
||||||
$this->delimiter = $delimiter;
|
$this->delimiter = $delimiter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -251,4 +251,25 @@ EOF;
|
||||||
[(version_compare(PHP_VERSION, '7.4') < 0) ? "\x0" : '', ','],
|
[(version_compare(PHP_VERSION, '7.4') < 0) ? "\x0" : '', ','],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test could be simpler, but Scrutinizer has a minor (and silly) problem.
|
||||||
|
*
|
||||||
|
* @dataProvider providerNull
|
||||||
|
*/
|
||||||
|
public function testSetDelimiterNull(?string $setNull): void
|
||||||
|
{
|
||||||
|
$reader = new Csv();
|
||||||
|
$reader->setDelimiter(',');
|
||||||
|
self::assertSame(',', $reader->getDelimiter());
|
||||||
|
$reader->setDelimiter($setNull);
|
||||||
|
self::assertSame($setNull, $reader->getDelimiter());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function providerNull(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[null],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue