Skip to content

false positive on private trait method #3637

@jacekkarczmarczyk

Description

@jacekkarczmarczyk

Bug report

phpstan: 0.12.33, bleeding edge

If a private trait method is not used in some class phpstan raises a warning that the method is not used even if it's used in other class

Code snippet that reproduces the problem

https://phpstan.org/r/72f07c19-65b2-4ab6-a12b-d42cd37cd60f

<?php declare(strict_types = 1);

trait Foo {
	private function bar(): void {} // Method Namaste::bar() is unused.
	private function baz(): void {} // Method HelloWorld::bar() is unused.
}

class HelloWorld
{
	use Foo;
	
	public function hello(): void {
		$this->bar();
	}
}

class Namaste
{
	use Foo;
	
	public function hello(): void {
		$this->baz();
	}
}

Expected output

no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions