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

Too strict parameter type for ViewModel#__construct $variables #239

Open
boesing opened this issue Jan 25, 2024 · 1 comment
Open

Too strict parameter type for ViewModel#__construct $variables #239

boesing opened this issue Jan 25, 2024 · 1 comment
Labels
Bug Something isn't working

Comments

@boesing
Copy link
Member

boesing commented Jan 25, 2024

Bug Report

Q A
Version(s) 2.33.0

Summary

The ViewModel now only allows maps but its inherited from JsonModel which does properly render list values as of now.

Current behavior

Argument 1 of Laminas\View\Model\JsonModel::__construct expects ArrayAccess<string, mixed>|iterable<string, mixed>|null, but list<array<array-key, mixed>>

How to reproduce

new Laminas\View\Model\JsonModel([1,2,3]);

Expected behavior

No error. Since a list is a valid JSON type, lists should be allowed.

@boesing boesing added the Bug Something isn't working label Jan 25, 2024
@RuesimOfCode
Copy link

RuesimOfCode commented Jan 26, 2024

I just wanted to create the same issue :)

I have one point to add.

Maybe there are more cases to match all forms of valid json. json_encode uses just mixed as first argument.

Example:

new JsonModel([1, 'test', null, true])

results in valid json

[
    1,
    "test",
    null,
    true
]

when returned by a HTTP endpoint

Best regards

ppaulis added a commit to ppaulis/laminas-view that referenced this issue Mar 18, 2024
ppaulis added a commit to ppaulis/laminas-view that referenced this issue Mar 18, 2024
ppaulis added a commit to ppaulis/laminas-view that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants