Are you sure the assignment to $employerId is correct as $this->getCurrentEmployerId() (which targets seregazhuk\HeadHunterApi...:getCurrentEmployerId()) seems to always return null.
This check looks for function or method calls that always return null and whose
return value is assigned to a variable.
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
36
{
37
$currentUser = $this->getCurrentUserInfo();
38
39
if(!isset($currentUser['employer']['id'])) {
40
throw new HeadHunterApiException('Cannot resolve employer id');
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
47
{
48
$currentUser = $this->getCurrentUserInfo();
49
50
if(!isset($currentUser['manager']['id'])) {
51
throw new HeadHunterApiException('Cannot resolve manager id');
It seems like you code against a specific sub-type and not the parent class seregazhuk\HeadHunterApi\EndPoints\Endpoint as the method info() does only exist in the following sub-classes of seregazhuk\HeadHunterApi\EndPoints\Endpoint: seregazhuk\HeadHunterApi\EndPoints\Me. Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example:
abstractclassUser{/** @return string */abstractpublicfunctiongetPassword();}classMyUserextendsUser{publicfunctiongetPassword(){// return something}publicfunctiongetDisplayName(){// return some name.}}classAuthSystem{publicfunctionauthenticate(User$user){$this->logger->info(sprintf('Authenticating %s.',$user->getDisplayName()));// do something.}}
In the above example, the authenticate() method works fine as long as you just pass
instances of MyUser. However, if you now also want to pass a different sub-classes
of User which does not have a getDisplayName() method, the code will break.
classAuthSystem{publicfunctionauthenticate(User$user){if($userinstanceofMyUser){$this->logger->info(/** ... */);}// or alternativelyif(!$userinstanceofMyUser){thrownew\LogicException('$user must be an instance of MyUser, '.'other instances are not supported.');}}}
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.