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 ClientInterface $client |
||
27 | 9 | */ |
|
28 | private function __construct(ClientInterface $client) |
||
32 | |||
33 | /** |
||
34 | * Create a new AsyncClient based on the loop and other options pass. |
||
35 | * |
||
36 | * @param LoopInterface $loop |
||
37 | * @param string $token Instructions to fetch the token: https://blog.travis-ci.com/2013-01-28-token-token-token/ |
||
38 | * @param array $options |
||
39 | * @return AsyncClient |
||
40 | 1 | */ |
|
41 | public static function create( |
||
58 | |||
59 | public function hydrate(string $resource): CancellablePromiseInterface |
||
63 | |||
64 | public function extract(ResourceInterface $resource): CancellablePromiseInterface |
||
68 | |||
69 | /** |
||
70 | * Create an AsyncClient from a ApiClients\Foundation\ClientInterface. |
||
71 | * Be sure to pass in a client with the options from ApiSettings and the Async namespace suffix. |
||
72 | * |
||
73 | 1 | * @param ClientInterface $client |
|
74 | * @return AsyncClient |
||
75 | 1 | */ |
|
76 | public static function createFromClient(ClientInterface $client): self |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | public function repository(string $repository): CancellablePromiseInterface |
||
88 | |||
89 | /** |
||
90 | * Warning this a intensive operation as it has to make a call for each hook |
||
91 | * to turn it into a Repository!!! |
||
92 | * |
||
93 | * Take a look at examples/repositories-async.php on how to limit the amount of |
||
94 | * concurrent requests. |
||
95 | * |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | public function repositories(callable $filter = null): ObservableInterface |
||
114 | |||
115 | 1 | /** |
|
116 | * {@inheritdoc} |
||
117 | 1 | */ |
|
118 | public function user(): PromiseInterface |
||
122 | |||
123 | 1 | /** |
|
124 | * {@inheritdoc} |
||
125 | 1 | */ |
|
126 | 1 | public function sshKey(int $id): PromiseInterface |
|
130 | |||
131 | /** |
||
132 | * @return ObservableInterface |
||
133 | 1 | */ |
|
134 | public function hooks(): ObservableInterface |
||
140 | |||
141 | /** |
||
142 | * {@inheritdoc} |
||
143 | 1 | */ |
|
144 | public function accounts(): ObservableInterface |
||
150 | |||
151 | /** |
||
152 | * {@inheritdoc} |
||
153 | */ |
||
154 | public function broadcasts(): ObservableInterface |
||
160 | } |
||
161 |
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: