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

Wrong typing on fetchAll() #27

Closed
ppaulis opened this issue Apr 14, 2022 · 4 comments · Fixed by #28 or #29
Closed

Wrong typing on fetchAll() #27

ppaulis opened this issue Apr 14, 2022 · 4 comments · Fixed by #28 or #29
Assignees
Labels
Bug Something isn't working Documentation Enhancement New feature or request
Milestone

Comments

@ppaulis
Copy link
Contributor

ppaulis commented Apr 14, 2022

Bug Report

Q A
Version(s) 1.6.1

Current behaviour

In:

$queryParams = $event->getQueryParams() ?: [];

the fetchAll() receives either an instance of Laminas\Stdlib\Parameters or an array.

The definition of the generated method stubs (and the parent method) is:

/**
     * Fetch all or a subset of resources
     *
     * @param  array $params
     * @return ApiProblem|mixed
     */
    public function fetchAll($params = [])
    {

Imho, in addition to problems with tools like PHPStan, this leads to all sorts of misunderstandings when trying to treat $params as an array. E.g. :

array_key_exists('my-key', $params)

generates :

Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, Laminas\Stdlib\Parameters given

Expected behaviour

Wouldn't it be better to enforce a strict typing on Laminas\Stdlib\Parameters? And let the user decide if $params should be transformed into an array?

Thanks and greetings,
Pascal

@ppaulis ppaulis added the Bug Something isn't working label Apr 14, 2022
@Ocramius
Copy link
Member

Would you be able to send a patch/proposal? Easier to review what you have in mind on a diff.

@Ocramius Ocramius added Documentation Enhancement New feature or request and removed Bug Something isn't working labels Apr 17, 2022
@ppaulis
Copy link
Contributor Author

ppaulis commented Apr 17, 2022

@Ocramius I can do that 👍 I'll get back to you asap.

@ppaulis
Copy link
Contributor Author

ppaulis commented Apr 19, 2022

@Ocramius I opened the PR #28. This is for discussion only because of the BC break it causes in the api-tools-admin repository. If you think this is worth pursuing, let me know how you'd like to handle it :-)

@Ocramius Ocramius added the Bug Something isn't working label Apr 19, 2022
@Ocramius Ocramius added this to the 1.6.2 milestone Apr 19, 2022
@Ocramius Ocramius self-assigned this Apr 19, 2022
@Ocramius
Copy link
Member

Handled in #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Documentation Enhancement New feature or request
Projects
None yet
2 participants