for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Converter;
use App\Entity\User;
class UserStringConverter {
public function convert(User $user): string {
if(empty($user->getLastname()) && empty($user->getFirstname())) {
return $user->getUsername();
} else if(empty($user->getFirstname())) {
return sprintf('%s (%s)', $user->getFirstname(), $user->getUsername());
$user->getFirstname()
App\Entity\User::getFirstname()
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.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
} else if(empty($user->getLastname())) {
return sprintf('%s (%s)', $user->getLastname(), $user->getUsername());
$user->getLastname()
App\Entity\User::getLastname()
}
return sprintf('%s, %s (%s)', $user->getLastname(), $user->getFirstname(), $user->getUsername());
This check looks for function or method calls that always return null and whose return value is used.
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.