Skip to content
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

PHP/IniSet: add support for PHP 8.0+ named parameters + bug fix #2161

Merged
merged 4 commits into from
Dec 20, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 19, 2022

PHP/IniSet: add support for PHP 8.0+ named parameters

  1. Adjusted the way the correct parameters are retrieved to use the new PHPCSUtils 1.0.0-alpha4 PassedParameters::getParameterFromStack() method.
  2. Verified the parameter names used are in line with the names as per the PHP 8.0 release.
    PHP itself renamed a lot of parameters in PHP 8.0. As named parameters did not exist before PHP 8.0, the parameter name as per PHP 8.0 (or above) is the only relevant name.
    Ref: https://www.php.net/manual/en/function.ini-set.php

Includes additional unit tests.

PHP/IniSet: prevent some false positives

The 'raw' key in the parameter arrays returned from the PassedParameters class contains - as per the name - the raw contents of the parameter.

Since PHPCSUtils 1.0.0-alpha4, the return array also contain a 'clean' index, which contains the contents of the parameter cleaned of comments.

By switching to using that key, some false positives/incorrect error message being thrown situations get prevented.

Includes unit tests demonstrating the issue and safeguarding the fix.

Includes ensuring that the information displayed in the error message will also no longer contain comments.

PHP/IniSet: minor code simplification

Check using empty() instead ! isset() for efficiency as it will prevent a potentially unnecessary call to in_array().

PHP/IniSet: minor message tweak for clarity

1. Adjusted the way the correct parameters are retrieved to use the new PHPCSUtils 1.0.0-alpha4 `PassedParameters::getParameterFromStack()` method.
2. Verified the parameter names used are in line with the names as per the PHP 8.0 release.
    PHP itself renamed a lot of parameters in PHP 8.0. As named parameters did not exist before PHP 8.0, the parameter name as per PHP 8.0 (or above) is the only relevant name.
    Ref: https://www.php.net/manual/en/function.ini-set.php

Includes additional unit tests.
The `'raw'` key in the parameter arrays returned from the `PassedParameters` class contains - as per the name - the _raw_ contents of the parameter.

Since PHPCSUtils 1.0.0-alpha4, the return array also contain a `'clean'` index, which contains the contents of the parameter cleaned of comments.

By switching to using that key, some false positives/incorrect error message being thrown situations get prevented.

Includes unit tests demonstrating the issue and safeguarding the fix.

Includes ensuring that the information displayed in the error message will also no longer contain comments.
Check using `empty()` instead `! isset()` for efficiency as it will prevent a potentially unncessary call to `in_array()`.
Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dingo-d dingo-d merged commit c354ee5 into develop Dec 20, 2022
@dingo-d dingo-d deleted the feature/iniset-use-phpcsutils-support-modern-php branch December 20, 2022 08:51
@jrfnl jrfnl mentioned this pull request Jan 7, 2023
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants