1 | <?php |
||
19 | class NativeShare extends AbstractShare { |
||
20 | /** |
||
21 | * @var IServer $server |
||
22 | */ |
||
23 | private $server; |
||
24 | |||
25 | /** |
||
26 | * @var string $name |
||
27 | */ |
||
28 | private $name; |
||
29 | |||
30 | /** |
||
31 | * @var NativeState $state |
||
32 | */ |
||
33 | private $state; |
||
34 | |||
35 | /** |
||
36 | * @param IServer $server |
||
37 | * @param string $name |
||
38 | */ |
||
39 | 256 | public function __construct($server, $name) { |
|
44 | |||
45 | /** |
||
46 | * @throws \Icewind\SMB\Exception\ConnectionException |
||
47 | * @throws \Icewind\SMB\Exception\AuthenticationException |
||
48 | * @throws \Icewind\SMB\Exception\InvalidHostException |
||
49 | */ |
||
50 | 256 | protected function getState() { |
|
59 | |||
60 | /** |
||
61 | * Get the name of the share |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 1 | public function getName() { |
|
68 | |||
69 | 256 | private function buildUrl($path) { |
|
79 | |||
80 | /** |
||
81 | * List the content of a remote folder |
||
82 | * |
||
83 | * @param string $path |
||
84 | * @return \Icewind\SMB\IFileInfo[] |
||
85 | * |
||
86 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
87 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
88 | */ |
||
89 | 256 | public function dir($path) { |
|
90 | 256 | $files = []; |
|
91 | |||
92 | 256 | $dh = $this->getState()->opendir($this->buildUrl($path)); |
|
93 | 256 | while ($file = $this->getState()->readdir($dh)) { |
|
94 | 256 | $name = $file['name']; |
|
95 | 256 | if ($name !== '.' and $name !== '..') { |
|
96 | 102 | $fullPath = $path . '/' . $name; |
|
97 | 102 | $files [] = new NativeFileInfo($this, $fullPath, $name, function () use ($fullPath) { |
|
98 | 102 | return $this->getStat($fullPath); |
|
99 | 102 | }); |
|
100 | 102 | } |
|
101 | 256 | } |
|
102 | |||
103 | 256 | $this->getState()->closedir($dh); |
|
104 | 256 | return $files; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * @param string $path |
||
109 | * @return \Icewind\SMB\IFileInfo |
||
110 | */ |
||
111 | 33 | public function stat($path) { |
|
114 | |||
115 | /** |
||
116 | * Multibyte unicode safe version of basename() |
||
117 | * |
||
118 | * @param string $path |
||
119 | * @link http://php.net/manual/en/function.basename.php#121405 |
||
120 | * @return string |
||
121 | */ |
||
122 | 33 | protected static function mb_basename($path) { |
|
131 | |||
132 | 114 | private function getStat($path) { |
|
135 | |||
136 | /** |
||
137 | * Create a folder on the share |
||
138 | * |
||
139 | * @param string $path |
||
140 | * @return bool |
||
141 | * |
||
142 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
143 | * @throws \Icewind\SMB\Exception\AlreadyExistsException |
||
144 | */ |
||
145 | 256 | public function mkdir($path) { |
|
148 | |||
149 | /** |
||
150 | * Remove a folder on the share |
||
151 | * |
||
152 | * @param string $path |
||
153 | * @return bool |
||
154 | * |
||
155 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
156 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
157 | */ |
||
158 | 256 | public function rmdir($path) { |
|
161 | |||
162 | /** |
||
163 | * Delete a file on the share |
||
164 | * |
||
165 | * @param string $path |
||
166 | * @return bool |
||
167 | * |
||
168 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
169 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
170 | */ |
||
171 | 134 | public function del($path) { |
|
174 | |||
175 | /** |
||
176 | * Rename a remote file |
||
177 | * |
||
178 | * @param string $from |
||
179 | * @param string $to |
||
180 | * @return bool |
||
181 | * |
||
182 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
183 | * @throws \Icewind\SMB\Exception\AlreadyExistsException |
||
184 | */ |
||
185 | 28 | public function rename($from, $to) { |
|
188 | |||
189 | /** |
||
190 | * Upload a local file |
||
191 | * |
||
192 | * @param string $source local file |
||
193 | * @param string $target remove file |
||
194 | * @return bool |
||
195 | * |
||
196 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
197 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
198 | */ |
||
199 | 113 | public function put($source, $target) { |
|
209 | |||
210 | /** |
||
211 | * Download a remote file |
||
212 | * |
||
213 | * @param string $source remove file |
||
214 | * @param string $target local file |
||
215 | * @return bool |
||
216 | * |
||
217 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
218 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
219 | * @throws \Icewind\SMB\Exception\InvalidPathException |
||
220 | * @throws \Icewind\SMB\Exception\InvalidResourceException |
||
221 | */ |
||
222 | 45 | public function get($source, $target) { |
|
249 | |||
250 | /** |
||
251 | * Open a readable stream to a remote file |
||
252 | * |
||
253 | * @param string $source |
||
254 | * @return resource a read only stream with the contents of the remote file |
||
255 | * |
||
256 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
257 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
258 | */ |
||
259 | 29 | public function read($source) { |
|
264 | |||
265 | /** |
||
266 | * Open a writeable stream to a remote file |
||
267 | * Note: This method will truncate the file to 0bytes first |
||
268 | * |
||
269 | * @param string $source |
||
270 | * @return resource a writeable stream |
||
271 | * |
||
272 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
273 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
274 | */ |
||
275 | 29 | public function write($source) { |
|
280 | |||
281 | /** |
||
282 | * Open a writeable stream and set the cursor to the end of the stream |
||
283 | * |
||
284 | * @param string $source |
||
285 | * @return resource a writeable stream |
||
286 | * |
||
287 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
288 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
289 | */ |
||
290 | 1 | public function append($source) { |
|
295 | |||
296 | /** |
||
297 | * Get extended attributes for the path |
||
298 | * |
||
299 | * @param string $path |
||
300 | * @param string $attribute attribute to get the info |
||
301 | * @return string the attribute value |
||
302 | */ |
||
303 | 14 | public function getAttribute($path, $attribute) { |
|
306 | |||
307 | /** |
||
308 | * Set extended attributes for the given path |
||
309 | * |
||
310 | * @param string $path |
||
311 | * @param string $attribute attribute to get the info |
||
312 | * @param string|int $value |
||
313 | * @return mixed the attribute value |
||
314 | */ |
||
315 | 8 | public function setAttribute($path, $attribute, $value) { |
|
322 | |||
323 | /** |
||
324 | * Set DOS comaptible node mode |
||
325 | * |
||
326 | * @param string $path |
||
327 | * @param int $mode a combination of FileInfo::MODE_READONLY, FileInfo::MODE_ARCHIVE, FileInfo::MODE_SYSTEM and FileInfo::MODE_HIDDEN, FileInfo::NORMAL |
||
328 | * @return mixed |
||
329 | */ |
||
330 | 8 | public function setMode($path, $mode) { |
|
333 | |||
334 | /** |
||
335 | * Start smb notify listener |
||
336 | * Note: This is a blocking call |
||
337 | * |
||
338 | * @param string $path |
||
339 | * @return INotifyHandler |
||
340 | */ |
||
341 | public function notify($path) { |
||
350 | |||
351 | 256 | public function __destruct() { |
|
354 | } |
||
355 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: