collmex icon indicating copy to clipboard operation
collmex copied to clipboard

Sort out the return type of ParserInterface::parse

Open oliverklee opened this issue 5 years ago • 2 comments

I've found this with the help of Psalm.

Should it be string[] or string[][]? And if it is a string[][], why does CsvResponse::parseCsv pass in a string, not a string[]?

oliverklee avatar Apr 02 '19 11:04 oliverklee

@mjaschen Do you have any input on this?

oliverklee avatar Jul 01 '19 09:07 oliverklee

Looking from the implementation side (SimpleParser.php) string[][] would be the correct answer[1] as the parser returns an array of parsed CSV lines which are arrays of strings.

When processing the result in CsvReponse it's also assumed that an array of arrays is passed as input[2]

[1] https://github.com/mjaschen/collmex/blob/master/src/Csv/SimpleParser.php#L37 [2] https://github.com/mjaschen/collmex/blob/master/src/Response/CsvResponse.php#L106

mjaschen avatar Jul 01 '19 10:07 mjaschen