-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PHP 8.1 auto_detect_line_endings deprecation notice #3394
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP 8.1 deprecates this setting, but doesn't remove support for it (yet).
For the purposes of PHPCS, it may still be relevant for this setting to be enabled as legacy projects being scanned, may contain files saved in the old Mac format.
With that in mind, I'd like to suggest to silence the deprecation notice instead of removing the ini change.
@ini_set('auto_detect_line_endings', true);
Silencing the deprecation notice should work fine until PHP 9.0, by which time it can be re-evaluated what should be done with this.
I guess we could do that but from the https://wiki.php.net/rfc/deprecations_php_8_1 ...
I guess we can't be sure that a legacy project is not depending on this ini setting but the chance of such a project using the latest version of PHPCS feels very slim. I think that not removing this now queues the work up for later. |
As an alternative, it could be considered to set the ini variable conditionally based on the PHP version detected. Personally, I think it would be a good compromise to:
(PHPCS 4.x will have a minimum PHP version of 7.2 and is likely to be released before PHP 9.0). Does that sound reasonable ? |
Doing some more reading - https://superuser.com/questions/439440/did-mac-os-lion-switch-to-using-line-feeds-lf-n-for-line-breaks-instead-of - it appears that some versions of excel on os x did save files with OS 9 line endings about a decade ago. I think one decent argument for removing this is because out-of-the-box git does not a recognise such line endings. OTOH suppressing with an @ is the path of least change. FWIW this code does originate from 2011 :)
|
I like the approach outlined by @jrfnl so I silenced the error in PHPCS 3 and removed the use of the ini setting in PHPCS 4. Thanks for raising this issue. |
auto_detect_line_endings is deprecated in PHP 8.1 - allegedly it has not been relevant for a while - https://www.mail-archive.com/[email protected]/msg107423.html