Skip to content

http_build_query type error is inaccurate #18400

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

Closed
nielsdos opened this issue Apr 22, 2025 · 4 comments
Closed

http_build_query type error is inaccurate #18400

nielsdos opened this issue Apr 22, 2025 · 4 comments

Comments

@nielsdos
Copy link
Member

Description

The following code:

<?php
enum X{case A;}
echo http_build_query(X::A);

Resulted in this output:

Uncaught TypeError: http_build_query(): Argument #1 ($data) must be of type array, X given

But I expected this output instead:

Uncaught TypeError: http_build_query(): Argument #1 ($data) must be of type array|object, X given

Although array|object is also a bit inaccurate, so the exact wording needs to be thought through

PHP Version

8.4+

Operating System

No response

@Girgias
Copy link
Member

Girgias commented Apr 23, 2025

I wonder if we should start deprecating the use of object properties as hashtables, as it is reasonably easy to get them with get_object_vars(). And it causes so many issues as objects can be so much more than just a hashmap of properties.

@nielsdos
Copy link
Member Author

I don't know, does it cause that many issues? Here it's just the wording of the message that should be improved 🙂

@Girgias
Copy link
Member

Girgias commented Apr 23, 2025

Well, this issue still exists #10229

As it is nor really possible to determine how such an object should behave

@nielsdos
Copy link
Member Author

Memory unlocked... Sure, future material though independent from this issue 🙂

nielsdos added a commit to nielsdos/php-src that referenced this issue Apr 26, 2025
Objects are also accepted still, so the error message is misleading.
@nielsdos nielsdos linked a pull request Apr 26, 2025 that will close this issue
nielsdos added a commit that referenced this issue Apr 26, 2025
* PHP-8.4:
  Fix GH-18400: http_build_query type error is inaccurate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants