These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | require_once __DIR__ . '/../vendor/autoload.php'; |
||
4 | |||
5 | $adapter = new \Habrahabr\Api\HttpAdapter\CurlAdapter(); |
||
6 | $adapter->setStrictSSL(true); |
||
7 | $adapter->setEndpoint(getenv('ENDPOINT')); |
||
8 | $adapter->setToken(getenv('TOKEN')); |
||
9 | $adapter->setClient(getenv('CLIENT')); |
||
10 | |||
11 | $client = new \Habrahabr\Api\Client($adapter); |
||
12 | |||
13 | $counters = $client->getTrackerResource()->getCounters(); |
||
0 ignored issues
–
show
|
|||
14 | $posts = $client->getTrackerResource()->getPostsFeed(); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Habrahabr\Api\Resources\ResourceInterface as the method getPostsFeed() does only exist in the following implementations of said interface: Habrahabr\Api\Resources\TrackerResource .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(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 implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
15 | $subs = $client->getTrackerResource()->getSubscribersFeed(); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Habrahabr\Api\Resources\ResourceInterface as the method getSubscribersFeed() does only exist in the following implementations of said interface: Habrahabr\Api\Resources\TrackerResource .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(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 implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
16 | $apps = $client->getTrackerResource()->getAppsFeed(); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Habrahabr\Api\Resources\ResourceInterface as the method getAppsFeed() does only exist in the following implementations of said interface: Habrahabr\Api\Resources\TrackerResource .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(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 implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
17 | |||
18 | $mentions = $client->getTrackerResource()->getMentions(); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Habrahabr\Api\Resources\ResourceInterface as the method getMentions() does only exist in the following implementations of said interface: Habrahabr\Api\Resources\TrackerResource .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(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 implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
19 | var_dump($mentions); |
||
20 | |||
21 |
Let’s take a look at an example:
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 implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: