1 | <?php |
||
19 | class ReactFactory |
||
20 | { |
||
21 | /** |
||
22 | * Build a react Event Loop. |
||
23 | * |
||
24 | * @return LoopInterface |
||
25 | */ |
||
26 | 110 | public static function buildEventLoop() |
|
27 | { |
||
28 | 110 | return EventLoopFactory::create(); |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * Build a React Dns Resolver. |
||
33 | * |
||
34 | * @param LoopInterface $loop |
||
35 | * @param string $dns |
||
36 | * |
||
37 | * @return DnsResolver |
||
38 | */ |
||
39 | public static function buildDnsResolver( |
||
40 | LoopInterface $loop, |
||
41 | $dns = '8.8.8.8' |
||
42 | ) { |
||
43 | $factory = new DnsResolverFactory(); |
||
44 | |||
45 | return $factory->createCached($dns, $loop); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param LoopInterface $loop |
||
50 | * @param DnsResolver|null $dns |
||
51 | * |
||
52 | * @return ConnectorInterface |
||
53 | */ |
||
54 | 1 | public static function buildConnector( |
|
55 | LoopInterface $loop, |
||
56 | DnsResolver $dns = null |
||
57 | ) { |
||
58 | 1 | return null !== $dns |
|
59 | 1 | ? new Connector($loop, ['dns' => $dns]) |
|
60 | 1 | : new Connector($loop); |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * Build a React Http Client. |
||
65 | * |
||
66 | * @param LoopInterface $loop |
||
67 | * @param ConnectorInterface|DnsResolver|null $connector Only pass this argument if you need to customize DNS |
||
68 | * behaviour. With react http client v0.5, pass a connector, |
||
69 | * with v0.4 this must be a DnsResolver. |
||
70 | * |
||
71 | * @return HttpClient |
||
72 | */ |
||
73 | 112 | public static function buildHttpClient( |
|
84 | |||
85 | /** |
||
86 | * Builds a React Http client v0.4 style. |
||
87 | * |
||
88 | * @param LoopInterface $loop |
||
89 | * @param DnsResolver|null $dns |
||
90 | * |
||
91 | * @return HttpClient |
||
92 | */ |
||
93 | protected static function buildHttpClient04( |
||
111 | |||
112 | /** |
||
113 | * Builds a React Http client v0.5 style. |
||
114 | * |
||
115 | * @param LoopInterface $loop |
||
116 | * @param DnsResolver|ConnectorInterface|null $connector |
||
117 | * |
||
118 | * @return HttpClient |
||
119 | */ |
||
120 | 112 | protected static function buildHttpClient05( |
|
146 | } |
||
147 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.