First, the RFC does not say what existing code should migrate to. I often
use
SplFileObject::fputcsv() for generating CSV files. The proceduralfputcsv()
is
not affected by this proposal, but it takes a stream resource, so it is not
a drop-in replacement for code that is structured around SplFileObject.
Is there an intended migration path that I have missed? If so, I think it
would
help to have it stated in the RFC, as the other sections in this RFC do.Second, SplFileObject::READ_CSV is not part of the proposal, which I think
leaves
the outcome in an inconsistent state. setCsvControl() is the only way to
configure the delimiter, enclosure and escape character used by READ_CSV;
the
constructor does not accept them. If setCsvControl() is removed in PHP 9
while
READ_CSV remains, READ_CSV is permanently locked to its defaults and
tab-separated files can no longer be read through it. The default value of
$escape is also already deprecated and scheduled to change, so what would
survive
is a flag that cannot be configured and whose defaults are still unsettled.Either READ_CSV should be deprecated alongside the four methods, or
setCsvControl() should be retained until a replacement API is available.
Just as a note here - the issues raised by Takuya don't appear to have
been responded to from what I can see - the deprecation as it stands
would mean that you still have the ability to read files and parse
them as CSVs via setting the READ_CSV flag in setFlags. This
outcome does resolve the issue in the linked PR (as following the
depreciation period, when the deprecated functions are removed then
there are no longer any arguments to set); but it also doesn't achieve
Girgias's aim of deprecating and removing the CSV functionality from
SPL; and if I am reading the code correctly then when the default for
$escape on \fgetcsv is changed, any code using READ_CSV will
behave differently on different versions of PHP with no ability to
manually make it consistent.
I think given the vote has passed, the READ_CSV flag also needs to
be deprecated. Ideally a similar migration from the deprecated
functions would have been provided (as I don't currently see any
simple way to pass a SPLFileInfo object to fgetcsv or similar),
but it is too late for that now I suspect.