Skip to content

Commit cfd86c8

Browse files
DaveLiddamentondrejmirtes
authored andcommitted
Fix fputcsv fields parameter (should be string[])
The `fields` parameter for `fputcsv` should be an array of strings. See [PHP manual](https://www.php.net/manual/en/function.fputcsv.php). This should fix [this snippet](https://phpstan.org/r/65420d60-d1fd-4eef-9ba3-e057672082ee) by correctly reporting an error on line `22`. Running the code in the snippet on PHP 8.0 (`PHP 8.0.0 (cli) (built: Dec 6 2020 06:56:11) ( NTS )`) results in this error: ``` PHP Fatal error: Uncaught Error: Object of class Person could not be converted to string in /home/vagrant/example/csv.php:24 Stack trace: #0 /home/vagrant/example/csv.php(24): fputcsv() #1 {main} thrown in /home/vagrant/example/csv.php on line 24 ``` NOTE: I've seen a similar error with PHP 7.3 too.
1 parent 68d1399 commit cfd86c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

resources/functionMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3004,7 +3004,7 @@
30043004
'fpassthru' => ['int|false', 'fp'=>'resource'],
30053005
'fpm_get_status' => ['array|false'],
30063006
'fprintf' => ['int', 'stream'=>'resource', 'format'=>'string', '...values='=>'string|int|float'],
3007-
'fputcsv' => ['int|false', 'fp'=>'resource', 'fields'=>'array', 'delimiter='=>'string', 'enclosure='=>'string', 'escape_char='=>'string'],
3007+
'fputcsv' => ['int|false', 'fp'=>'resource', 'fields'=>'string[]', 'delimiter='=>'string', 'enclosure='=>'string', 'escape_char='=>'string'],
30083008
'fputs' => ['int|false', 'fp'=>'resource', 'str'=>'string', 'length='=>'int'],
30093009
'fread' => ['string|false', 'fp'=>'resource', 'length'=>'int'],
30103010
'frenchtojd' => ['int', 'month'=>'int', 'day'=>'int', 'year'=>'int'],

0 commit comments

Comments
 (0)