Skip to content

Conversation

@samsonasik
Copy link
Member

@samsonasik samsonasik commented Sep 15, 2025

Given the following code:

    public function get(): array
    {
        return [
            'a' => false,
            'b' => 'b',
            'c' => true,
            'd' => $this->getNullable(),
            'class' => StripEmptyCombine::class,
            'opt' => [],
            'init' => false,
            'attrs' => [
                'x' => 'x',
                'class' => 'pick',
                'apply' => 'true',
                'head' => $this->trans('foo'),
            ],
        ];
    }

It currently got:

+    /**
+     * @return array<string, string|bool|never[]|array<string, string>|null>
+     */
     public function get(): array

that cause phpstan error:

  - '#Method get\(\) should return array<string, array\|bool\|string> but returns array<string, array<string, string>\|bool\|string>#'

see error at https://phpstan.org/r/15722015-5567-4305-aeac-8dda263328ef

@samsonasik
Copy link
Member Author

Use mixed[] seems the way, see https://phpstan.org/r/9bf0fc59-bc8a-4f22-a05f-c50560f36081

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit 7546e9a into main Sep 15, 2025
49 checks passed
@samsonasik samsonasik deleted the strip-never branch September 15, 2025 14:50
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