1 | <?php |
||
74 | class StdinHandler |
||
75 | { |
||
76 | protected $path; |
||
77 | protected $stream; |
||
78 | |||
79 | /** |
||
80 | * hasPath returns 'true' if the stdin handler has a path to a file. |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function hasPath() |
||
89 | |||
90 | /** |
||
91 | * hasStream returns 'true' if the stdin handler has opened a stream. |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function hasStream() |
||
99 | |||
100 | /** |
||
101 | * path returns the path to any file that was set as a redirection |
||
102 | * source, or `php://stdin` if none have been. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function path() |
||
110 | |||
111 | /** |
||
112 | * close closes the input stream if it was opened. |
||
113 | */ |
||
114 | public function close() |
||
122 | |||
123 | /** |
||
124 | * redirect specifies a path to a file that should serve as the |
||
125 | * source to read from. If the input path is '-' or empty, |
||
126 | * then output will be taken from php://stdin (or whichever source |
||
127 | * was provided via the 'redirect' method). |
||
128 | * |
||
129 | * @return $this |
||
130 | */ |
||
131 | public function redirect($path) |
||
139 | |||
140 | /** |
||
141 | * select chooses the source of the input stream based on whether or |
||
142 | * not the user provided the specified option or argument on the commandline. |
||
143 | * Stdin is selected if there is no user selection. |
||
144 | * |
||
145 | * @param InputInterface $input |
||
146 | * @param string $optionOrArg |
||
147 | * @return $this |
||
148 | */ |
||
149 | public function select(InputInterface $input, $optionOrArg) |
||
158 | |||
159 | /** |
||
160 | * getStream opens and returns the stdin stream (or redirect file). |
||
161 | */ |
||
162 | public function getStream() |
||
169 | |||
170 | /** |
||
171 | * setStream functions like 'select', and also sets up the $input |
||
172 | * object to read from the selected input stream e.g. when used |
||
173 | * with a question helper. |
||
174 | */ |
||
175 | public function setStream(InputInterface $input, $optionOrArg) |
||
184 | |||
185 | /** |
||
186 | * contents reads the entire contents of the standard input stream. |
||
187 | * |
||
188 | * @return string |
||
189 | */ |
||
190 | public function contents() |
||
204 | |||
205 | /** |
||
206 | * Returns 'true' if a path was specfied, and that path was not '-'. |
||
207 | */ |
||
208 | protected function pathProvided($path) |
||
212 | |||
213 | protected function getOptionOrArg(InputInterface $input, $optionOrArg) |
||
220 | } |
||
221 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.