1 | <?php |
||
16 | class Connection extends RawConnection { |
||
17 | const DELIMITER = 'smb:'; |
||
18 | const DELIMITER_LENGTH = 4; |
||
19 | |||
20 | /** @var Parser */ |
||
21 | private $parser; |
||
22 | |||
23 | 765 | public function __construct($command, Parser $parser, $env = array()) { |
|
27 | |||
28 | /** |
||
29 | * send input to smbclient |
||
30 | * |
||
31 | * @param string $input |
||
32 | */ |
||
33 | 765 | public function write($input) { |
|
36 | |||
37 | /** |
||
38 | * @throws ConnectException |
||
39 | */ |
||
40 | 765 | public function clearTillPrompt() { |
|
49 | |||
50 | /** |
||
51 | * get all unprocessed output from smbclient until the next prompt |
||
52 | * |
||
53 | * @param callable $callback (optional) callback to call for every line read |
||
54 | * @return string[] |
||
55 | * @throws AuthenticationException |
||
56 | * @throws ConnectException |
||
57 | * @throws ConnectionException |
||
58 | * @throws InvalidHostException |
||
59 | * @throws NoLoginServerException |
||
60 | */ |
||
61 | 762 | public function read(callable $callback = null) { |
|
91 | |||
92 | /** |
||
93 | * Check |
||
94 | * |
||
95 | * @param $line |
||
96 | * @return bool |
||
97 | */ |
||
98 | 765 | private function isPrompt($line) { |
|
101 | |||
102 | /** |
||
103 | * @param string $promptLine (optional) prompt line that might contain some info about the error |
||
104 | * @throws ConnectException |
||
105 | */ |
||
106 | private function unknownError($promptLine = '') { |
||
118 | |||
119 | 765 | public function close($terminate = true) { |
|
125 | } |
||
126 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.