string
casting in concatenation is redundant PHP-W1087When concatenating string with concatenation operator, implicitly casting a value to string
type is not necessary. All types are by default casted to string
.
class Greet
{
public function getMessage(): string
{
// implicitly casting value to string is redundant here, it does it by default
return 'Welcome ' . (string) $this->name;
}
}
class Greet
{
public function getMessage(): string
{
return 'Welcome ' . $this->name;
}
}