1 | <?php |
||
16 | final class Client |
||
17 | { |
||
18 | const USER_AGENT = 'PhpMastodon/0.0.1(+https://github.com/zonuexe/php-mastodon-client)'; |
||
19 | |||
20 | /** @var string */ |
||
21 | private $instance; |
||
22 | /** @var string|null */ |
||
23 | private $client_name; |
||
24 | /** @var \GuzzleHttp\Client */ |
||
25 | private $api_http_client; |
||
26 | /** @var \GuzzleHttp\Client */ |
||
27 | private $oauth_http_client; |
||
28 | |||
29 | /** |
||
30 | * @param string $instance |
||
31 | * @param array $options |
||
32 | */ |
||
33 | 10 | public function __construct($instance, array $options = []) |
|
41 | |||
42 | /** |
||
43 | * @param string $method "GET"|"POST" |
||
44 | * @param string $path |
||
45 | * @param array $options |
||
46 | * @param SessionStorage $session |
||
47 | * @return ResponseInterface |
||
48 | */ |
||
49 | 1 | public function requestAPI($method, $path, array $options, SessionStorage $session) |
|
55 | |||
56 | /** |
||
57 | * @return void |
||
58 | */ |
||
59 | 1 | public function setAPIHttpClient(\GuzzleHttp\Client $client) |
|
63 | |||
64 | /** |
||
65 | * @return \GuzzleHttp\Client |
||
66 | */ |
||
67 | 1 | private function getAPIHttpClient() |
|
77 | |||
78 | /** |
||
79 | * @param SessionStorage $session |
||
80 | * @return array |
||
81 | */ |
||
82 | 1 | private function getRequestAPIOptions(SessionStorage $session) |
|
97 | |||
98 | /** |
||
99 | * @return string |
||
100 | */ |
||
101 | 4 | public function getScheme() |
|
105 | |||
106 | /** |
||
107 | * @return string |
||
108 | */ |
||
109 | 4 | public function getHostname() |
|
116 | } |
||
117 |
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: