Skip to content

http_build_query type error is inaccurate #18400

Closed

Description

@ndossche

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

Activity

  1. Girgias commented on Apr 23, 2025

    @Girgias
    Member

    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.

  2. ndossche commented on Apr 23, 2025

    @ndossche
    MemberAuthor

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

  3. Girgias commented on Apr 23, 2025

    @Girgias
    Member

    Well, this issue still exists #10229

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

  4. ndossche commented on Apr 23, 2025

    @ndossche
    MemberAuthor

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

  5. added a commit that references this issue on Apr 26, 2025
    6a40c2e
  6. added 2 commits that reference this issue on Apr 26, 2025
    d36b029
    7a2bef0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions