1 | <?php |
||
18 | class ServerFactory |
||
19 | { |
||
20 | /** |
||
21 | * The host the server will run on. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $host = '127.0.0.1'; |
||
26 | |||
27 | /** |
||
28 | * The port to run on. |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $port = 8080; |
||
33 | |||
34 | /** |
||
35 | * The event loop instance. |
||
36 | * |
||
37 | * @var \React\EventLoop\LoopInterface |
||
38 | */ |
||
39 | protected $loop; |
||
40 | |||
41 | /** |
||
42 | * The routes to register. |
||
43 | * |
||
44 | * @var \Symfony\Component\Routing\RouteCollection |
||
45 | */ |
||
46 | protected $routes; |
||
47 | |||
48 | /** |
||
49 | * Console output. |
||
50 | * |
||
51 | * @var Symfony\Component\Console\Output\OutputInterface |
||
52 | */ |
||
53 | protected $consoleOutput; |
||
54 | |||
55 | /** |
||
56 | * Initialize the class. |
||
57 | * |
||
58 | * @param string $host |
||
59 | * @param int $port |
||
60 | * @return void |
||
|
|||
61 | */ |
||
62 | public function __construct(string $host, int $port) |
||
69 | |||
70 | /** |
||
71 | * Add the routes. |
||
72 | * |
||
73 | * @param \Symfony\Component\Routing\RouteCollection $routes |
||
74 | * @return $this |
||
75 | */ |
||
76 | public function withRoutes(RouteCollection $routes) |
||
82 | |||
83 | /** |
||
84 | * Set the loop instance. |
||
85 | * |
||
86 | * @param \React\EventLoop\LoopInterface $loop |
||
87 | * @return $this |
||
88 | */ |
||
89 | public function setLoop(LoopInterface $loop) |
||
95 | |||
96 | /** |
||
97 | * Set the console output. |
||
98 | * |
||
99 | * @param \Symfony\Component\Console\Output\OutputInterface $consoleOutput |
||
100 | * @return $this |
||
101 | */ |
||
102 | public function setConsoleOutput(OutputInterface $consoleOutput) |
||
108 | |||
109 | /** |
||
110 | * Set up the server. |
||
111 | * |
||
112 | * @return \Ratchet\Server\IoServer |
||
113 | */ |
||
114 | public function createServer(): IoServer |
||
134 | } |
||
135 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.