1 | <?php declare(strict_types=1); |
||
18 | final class AsyncClient implements AsyncClientInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var ClientInterface |
||
22 | */ |
||
23 | private $client; |
||
24 | |||
25 | /** |
||
26 | * @param LoopInterface $loop |
||
27 | * @param string $token |
||
28 | * @param array $options |
||
29 | * @return AsyncClient |
||
30 | */ |
||
31 | 1 | public static function create( |
|
32 | LoopInterface $loop, |
||
33 | string $token = '', |
||
34 | array $options = [] |
||
35 | ): self { |
||
36 | 1 | $options = ApiSettings::getOptions($token, 'Async', $options); |
|
37 | 1 | $client = Factory::create($loop, $options); |
|
38 | 1 | return new self($client); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param ClientInterface $client |
||
43 | * @return AsyncClient |
||
44 | */ |
||
45 | 8 | public static function createFromClient(ClientInterface $client): self |
|
49 | |||
50 | /** |
||
51 | * @param ClientInterface $client |
||
52 | */ |
||
53 | 9 | private function __construct(ClientInterface $client) |
|
57 | |||
58 | /** |
||
59 | * @param string $repository |
||
60 | * @return CancellablePromiseInterface |
||
61 | */ |
||
62 | 1 | public function repository(string $repository): CancellablePromiseInterface |
|
66 | |||
67 | /** |
||
68 | * @return ObservableInterface |
||
69 | */ |
||
70 | public function repositories(): ObservableInterface |
||
80 | |||
81 | /** |
||
82 | * @return PromiseInterface |
||
83 | */ |
||
84 | public function user(): PromiseInterface |
||
88 | |||
89 | /** |
||
90 | * @param int $id |
||
91 | * @return PromiseInterface |
||
92 | */ |
||
93 | 1 | public function sshKey(int $id): PromiseInterface |
|
97 | |||
98 | /** |
||
99 | * @return ObservableInterface |
||
100 | */ |
||
101 | public function hooks(): ObservableInterface |
||
107 | |||
108 | /** |
||
109 | * @return ObservableInterface |
||
110 | */ |
||
111 | public function accounts(): ObservableInterface |
||
117 | |||
118 | /** |
||
119 | * @return ObservableInterface |
||
120 | */ |
||
121 | public function broadcasts(): ObservableInterface |
||
127 | } |
||
128 |
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: