mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00

Normalize the behavior between the file functions and those on SplFileObject. Be consistent about throwing regardless of whether the delimiter etc is empty or has too many characters. I don't think it's worthwhile to distinguish these cases. Back when we looked into this originally, there was some hope that we might want to add support for multiple-character delimiter etc, but after a cursory look, I really don't think this is going to happen (for fputcsv maybe, but for fgetcsv this just makes an already broken function much more complicated.) Closes GH-6188.
27 lines
599 B
PHP
27 lines
599 B
PHP
--TEST--
|
|
SPL: SplFileObject::setCsvControl error 002
|
|
--CREDITS--
|
|
Erwin Poeze <erwin.poeze at gmail.com>
|
|
--FILE--
|
|
<?php
|
|
file_put_contents('csv_control_data_error002.csv',
|
|
<<<CDATA
|
|
'groene appelen'|10
|
|
'gele bananen'|20
|
|
'rode kersen'|30
|
|
CDATA
|
|
);
|
|
$s = new SplFileObject('csv_control_data_error002.csv');
|
|
$s->setFlags(SplFileObject::READ_CSV);
|
|
try {
|
|
$s->setCsvControl('|', 'two');
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
unlink('csv_control_data_error002.csv');
|
|
?>
|
|
--EXPECT--
|
|
SplFileObject::setCsvControl(): Argument #2 ($enclosure) must be a single character
|