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

Is there any reason why function parse_url is Discouraged? #401

Open
VladyslavSikailo opened this issue Jun 3, 2022 · 1 comment
Open
Labels

Comments

@VladyslavSikailo
Copy link

VladyslavSikailo commented Jun 3, 2022

When I use parse_url() function - phpcs shows me the following error:

 39 | WARNING | The use of function parse_url() is discouraged

Is there any reason why I should not use this function?
I don't see any.

Do I have any alternative functions to use?
It was possible to use \Zend\Uri\Http but it's removed starting from Magento 2.4.1.

Can I somehow remove it from the Discouraged function list using a custom ruleset?
Seems like I can't.
Update: I have disabled it using the following sentence, but not sure whether it right way

    <rule ref="Magento2.Functions.DiscouragedFunction">
        <properties>
            <property name="forbiddenFunctions" type="array">
                <element key="!parse_url" value="null"/>
            </property>
        </properties>
    </rule>

See: https://github.com/magento/magento-coding-standard/blob/develop/Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php#L103

@VladyslavSikailo VladyslavSikailo added the bug Something isn't working label Jun 3, 2022
@m2-assistant
Copy link

m2-assistant bot commented Jun 3, 2022

Hi @Dren7755. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


@VladyslavSikailo VladyslavSikailo changed the title Is there any reason why function parse_url is Discouraged Is there any reason why function parse_url is Discouraged? Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant