Skip to content

Offset does not exist on array<int, mixed> #4850

@ju5t

Description

@ju5t

Bug report

Version: 0.12.83

Whenever I use the splat operator in combination with named arguments in PHP 8 I get the following error when running phpstan.

Offset 'key' does not exist on array<int, mixed>.

Code snippet that reproduces the problem

A failing code snippet can be found here: https://phpstan.org/r/fef73ac6-edb2-4c18-bbf1-953d722e8d5f

As a reference:

<?php declare(strict_types = 1);

class HelloWorld
{
	public function __construct(...$args)
	{
		print($args['hostname']);
	}
}

$hello = new HelloWorld(hostname: 'localhost');

Expected output

To be fair I'm really new to phpstan. @ondrejmirtes asked me to raise this report based on the following discussion: #4849. If I can help with some more information or details, let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions