Issues (97)

src/Converter/UserStringConverter.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace App\Converter;
4
5
use App\Entity\User;
6
7
class UserStringConverter {
8
    public function convert(User $user): string {
9
        if(empty($user->getLastname()) && empty($user->getFirstname())) {
10
            return $user->getUsername();
11
        } else if(empty($user->getFirstname())) {
12
            return sprintf('%s (%s)', $user->getFirstname(), $user->getUsername());
0 ignored issues
show
Are you sure the usage of $user->getFirstname() targeting App\Entity\User::getFirstname() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
13
        } else if(empty($user->getLastname())) {
14
            return sprintf('%s (%s)', $user->getLastname(), $user->getUsername());
0 ignored issues
show
Are you sure the usage of $user->getLastname() targeting App\Entity\User::getLastname() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
15
        }
16
17
        return sprintf('%s, %s (%s)', $user->getLastname(), $user->getFirstname(), $user->getUsername());
18
    }
19
}