diff options
| author | Craig Duncan <git@duncanc.co.uk> | 2019-04-28 00:44:48 +0200 |
|---|---|---|
| committer | Peter Kokot <peterkokot@gmail.com> | 2019-04-28 00:44:48 +0200 |
| commit | 91c6fb881e7b98c968d270bdf7f0051b4c2b2c9c (patch) | |
| tree | 7f618902bf1cc31abb692c6b8351e930a2710456 | |
| parent | 57d5dc5688a898be705053819519815b122c5ab7 (diff) | |
| download | php-git-91c6fb881e7b98c968d270bdf7f0051b4c2b2c9c.tar.gz | |
Fix #77024: SplFileObject::__toString() may return array
- Correct the behaviour of casting spl files to strings
- Add a test for Bug 77024
| -rw-r--r-- | ext/spl/spl_directory.c | 2 | ||||
| -rw-r--r-- | ext/spl/tests/bug77024.phpt | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 47b3521d63..4f274641e8 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -3111,7 +3111,7 @@ static const zend_function_entry spl_SplFileObject_functions[] = { SPL_ME(SplFileObject, seek, arginfo_file_object_seek, ZEND_ACC_PUBLIC) /* mappings */ SPL_MA(SplFileObject, getCurrentLine, SplFileObject, fgets, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC) - SPL_MA(SplFileObject, __toString, SplFileObject, current, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC) + SPL_MA(SplFileObject, __toString, SplFileObject, fgets, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC) PHP_FE_END }; diff --git a/ext/spl/tests/bug77024.phpt b/ext/spl/tests/bug77024.phpt new file mode 100644 index 0000000000..d61dc941d4 --- /dev/null +++ b/ext/spl/tests/bug77024.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #77024 SplFileObject::__toString() may return array +--FILE-- +<?php + +$file = new SplTempFileObject; +$file->fputcsv(['foo', 'bar', 'baz']); +$file->rewind(); +$file->setFlags(SplFileObject::READ_CSV); +echo $file . "\n"; + +$tmp = tempnam(sys_get_temp_dir(), "php-tests-"); +file_put_contents($tmp, "line1\nline2\nline3\n"); +$file = new SplFileObject($tmp); +$file->rewind(); +echo $file . "\n"; +unset($file); +unlink($tmp); + +?> +--EXPECT-- +foo,bar,baz + +line1 |
