It seems like the GitHub access token used for retrieving details about this repository from
GitHub became invalid. This might prevent certain types of inspections from being run (in
particular,
everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
and let?s assume the following content of Bar.php:
// Bar.phpnamespaceOtherDir;useSomeDir\Foo;// This now conflicts the class OtherDir\Foo
If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the
same runtime, you will see a PHP error such as the following:
PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as OtherDir/Foo.php does not necessarily have to be loaded and the
error is only triggered if it is loaded before OtherDir/Bar.php, this problem
might go unnoticed for a while. In order to prevent this error from surfacing,
you must import the namespace with a different alias:
// Bar.phpnamespaceOtherDir;useSomeDir\FooasSomeDirFoo;// There is no conflict anymore.
Loading history...
11
};
12
13
class HttpClient
14
{
15
protected const METHOD_GET = 'GET';
16
17
protected const METHOD_POST = 'POST';
18
19
/**
20
* @var ContainerInterface $config
21
*/
22
protected $config;
23
24
/**
25
* @var GuzzleClient
26
*/
27
protected $client;
28
29
/**
30
* @param ContainerInterface $config
31
*/
32
public function __construct(ContainerInterface $config)
33
{
34
$this->config = $config;
35
$this->client = new GuzzleClient([
36
'base_uri' => $this->getBaseUri(),
37
$this->config->get('timeout'),
38
]);
39
}
40
41
/**
42
* Returns base API url
43
*
44
* @return string
45
*/
46
protected function getBaseUri(): string
47
{
48
return sprintf(
49
'%s/%s%s/',
50
$this->config->get('url'),
51
$this->config->get('bot_prefix'),
52
$this->config->get('token')
53
);
54
}
55
56
/**
57
* Performs the request and returns the Response contents
58
*
59
* @param string $apiMethodName
60
* @param array $requestOptions
61
*
62
* @return null|string
63
*/
64
public function request(string $apiMethodName, array $requestOptions = []): ?string
65
{
66
$method = static::METHOD_POST;
67
68
if (!isset($requestOptions['multipart']) && $this->config->get('method') == static::METHOD_GET) {
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: