+
Skip to content

Integer ranges in array keys do not carry through generics #7087

@lcdennison

Description

@lcdennison

Bug report

Using 1.5.7.

In the below example link, I created two methods (foo and bar) that accept an array parameter. foo declares an explicit return of array<int<0,max>, mixed>, whereas bar uses generics to simply pass through the input type. The class has two properties, array1 and array2 that both expect array<int<0,max>, mixed>. The result of foo can be successfully assigned to a property, but the result of bar cannot. It would seem the generics I used for bar do not carry through the integer range int<0,max> for keys. It comes out as simply int.

Or I'm using generics incorrectly?

Code snippet that reproduces the problem

https://phpstan.org/r/e9901d5a-abb7-47ba-8706-204c3890a6fb

Expected output

I'd expect integer ranges to be carried through the generics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载