Skip to content

Constructor has unused parameter #1917

@srebbsrebb

Description

@srebbsrebb

Summary of a problem or a feature request

If you pass the parameters from a constructor via ...func_get_args to the parent constructor, phpstan detects them as unused.

https://phpstan.org/r/21fbfdfe-23d4-4088-b2bf-7de5a786bc64

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

class A {
	private $a;
	private $b;
	
	public function __construct($a, $b)
	{
		$this->a = $a;
		$this->b = $b;
		
		var_dump([$this->a, $this->b]);
	}
}

class B extends A {
	function __construct($a, $b) {
		parent::__construct(...func_get_args());
	}
}

$b = new B(1, 2);

Expected output

The issue is reported incorrectly

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions