Skip to content

Strict comparison using === between class-string and false will always evaluate to false #4741

@hskrasek

Description

@hskrasek

Bug report

I'm running into an issue in regards to get_class being yet another core function that returns multiple types. PHPStan is claiming Strict comparison using === between class-string and false will always evaluate to false., even though the logic comparison here is valid code based on the functions documented returns. Is there a way to trick PHPStan into thinking this is valid, outside of ignoring it?

<?php declare(strict_types = 1);

function isAnObject($object): bool {
	$class = get_class($object);
	
	if ($class === false) {
		return false;
	}
	
	return true;
}

https://phpstan.org/r/49184b59-e1b5-43aa-bb71-77d8d1354164

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions