Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict comparison using === between class-string<XXX> and 'YYY' will always evaluate to false. #3633

Closed
jacekkarczmarczyk opened this issue Jul 20, 2020 · 2 comments · Fixed by phpstan/phpstan-src#2044
Labels
Milestone

Comments

@jacekkarczmarczyk
Copy link

Bug report

phpstan 0.12.33

Following code throws an error

Code snippet that reproduces the problem

https://phpstan.org/r/079841f1-1961-44a4-acfa-c8a308fea2fc

<?php declare(strict_types = 1);

trait Foo {
	public function test(): void {
		if (get_class($this) === HelloWorld::class) {
			echo "OK";
		}
		if (get_class($this) === OtherClass::class) {
			echo "OK";
		}
	}
}

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

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

Expected output

No error

Additional notes

Might be related to #3632

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jul 22, 2020
@ondrejmirtes
Copy link
Member

Agreed, issues like these shouldn't be reported in traits.

@github-actions
Copy link

github-actions bot commented Feb 9, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants