PHP 7.4/8.4 | :sparkles: New `PHPCompatibility.ParameterValues.RemovedProprietaryCSVEscaping` sniff by jrfnl · Pull Request #1787 · PHPCompatibility/PHPCompatibility

added 2 commits

October 7, 2024 00:51
…Escaping` sniff

> - Standard:
>  . fputcsv() and fgetcsv() now accept an empty string as $escape argument,
>    which disables the proprietary PHP escaping mechanism. The behavior of
>    str_getcsv() has been adjusted accordingly (formerly, an empty string was
>    identical to using the default).

This adds a new sniff to detect code subject to this change.

The one thing I'm not 100% sure about, is whether this should be an `error` or a `warning`.

In PHP 7.3 and lower, passing an empty string as `$escape` to `fputcsv()` and `fgetcsv()` would result in a PHP warning: "Warning: fputcsv(): escape must be a character", not in a fatal error, but as the resulting CSV data can be significantly different - which could break imports/exports, I've elected to make it an error for PHPCompatibility anyway.

Refs:
* https://wiki.php.net/rfc/kill-csv-escaping (step 1)
* https://github.com/php/php-src/blob/004cb827501d1ddaf98daacb185a53e0816f78a7/UPGRADING#L489-L493
* php/php-src 3515
* php/php-src@3b0f051

@jrfnl jrfnl mentioned this pull request

Oct 6, 2024

58 tasks

wimg

wimg approved these changes Oct 7, 2024

@wimg wimg deleted the php-7.4-8.4/new-removedproprietarycsvescaping-sniff branch

October 7, 2024 07:09

@jrfnl jrfnl mentioned this pull request

Sep 1, 2025

@jrfnl jrfnl changed the title PHP 7.4/8.4 | New PHPCompatibility.ParameterValues.RemovedProprietaryCSVEscaping sniff PHP 7.4/8.4 | ✨ New PHPCompatibility.ParameterValues.RemovedProprietaryCSVEscaping sniff

Oct 12, 2025