Skip to content

True inferred as bool #11435

Description

@HypeMC

Bug report

It seems that the optional key somehow becomes bool instead of true:

/**
 * @implements \IteratorAggregate<int, array{
 *     routeName: string,
 *     optional?: true,
 * }>
 */
class Example implements \IteratorAggregate
{
    /**
     * @param list<array{
     *     routeName: string,
     *     optional?: true,
     * }> $elements
     */
    public function __construct(
        private array $elements,
    ) {
    }

    public function getIterator(): \Traversable
    {
        return new \ArrayIterator($this->elements);
    }
}

Code snippet that reproduces the problem

https://phpstan.org/r/16c5ac66-1810-424e-a068-38bbccfaa914

Expected output

No errors

Did PHPStan help you today? Did it make you happy in any way?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions