Skip to content

Cast CURL constants to string that cause a InvalidArgumentException #63

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

Merged
merged 1 commit into from
Nov 25, 2019
Merged

Cast CURL constants to string that cause a InvalidArgumentException #63

merged 1 commit into from
Nov 25, 2019

Conversation

codedmonkey
Copy link
Contributor

Followup on #62

After some quick testing, I noticed some inconsistencies because the Symfony source code doesn't use strict typing. So when you pass the CURL constants as array keys, it will be converted to strings by the OptionsResolver itself.

# This works
        $resolver->setDefaults(
            [
                CURLOPT_HEADER => false
            ]
        );

# This doesn't work
        $resolver->setDefault(CURLOPT_HEADER, false);

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

the reason why the array works might also be the weird way of how php handles array keys (autoconverting strings to integer when they look like they could be numeric)

anyway, the fix looks right, thanks!

@dbu dbu merged commit 4336b53 into php-http:master Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants