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 | 510 | 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 | 510 | protected function getState() { |
|
59 | |||
60 | /** |
||
61 | * Get the name of the share |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 2 | public function getName() { |
|
68 | |||
69 | 510 | 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 | 510 | public function dir($path) { |
|
90 | 510 | $files = []; |
|
91 | |||
92 | 510 | $dh = $this->getState()->opendir($this->buildUrl($path)); |
|
93 | 510 | while ($file = $this->getState()->readdir($dh)) { |
|
94 | 510 | $name = $file['name']; |
|
95 | 510 | if ($name !== '.' and $name !== '..') { |
|
96 | 204 | $fullPath = $path . '/' . $name; |
|
97 | 204 | $files [] = new NativeFileInfo($this, $fullPath, $name, function () use ($fullPath) { |
|
98 | 204 | return $this->getStat($fullPath); |
|
99 | 204 | }); |
|
100 | 102 | } |
|
101 | 255 | } |
|
102 | |||
103 | 510 | $this->getState()->closedir($dh); |
|
104 | 510 | return $files; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * @param string $path |
||
109 | * @return \Icewind\SMB\IFileInfo |
||
110 | */ |
||
111 | 66 | public function stat($path) { |
|
114 | |||
115 | 228 | /** |
|
116 | 228 | * Get fstat |
|
117 | * |
||
118 | * @param string $path |
||
119 | * @return array |
||
120 | */ |
||
121 | private function getStat($path) { |
||
124 | |||
125 | /** |
||
126 | * Create a folder on the share |
||
127 | * |
||
128 | 510 | * @param string $path |
|
129 | 510 | * @return bool |
|
130 | * |
||
131 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
132 | * @throws \Icewind\SMB\Exception\AlreadyExistsException |
||
133 | */ |
||
134 | public function mkdir($path) { |
||
137 | |||
138 | /** |
||
139 | * Remove a folder on the share |
||
140 | * |
||
141 | 510 | * @param string $path |
|
142 | 510 | * @return bool |
|
143 | * |
||
144 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
145 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
146 | */ |
||
147 | public function rmdir($path) { |
||
150 | |||
151 | /** |
||
152 | * Delete a file on the share |
||
153 | * |
||
154 | 266 | * @param string $path |
|
155 | 266 | * @return bool |
|
156 | * |
||
157 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
158 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
159 | */ |
||
160 | public function del($path) { |
||
163 | |||
164 | /** |
||
165 | * Rename a remote file |
||
166 | * |
||
167 | * @param string $from |
||
168 | 56 | * @param string $to |
|
169 | 56 | * @return bool |
|
170 | * |
||
171 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
172 | * @throws \Icewind\SMB\Exception\AlreadyExistsException |
||
173 | */ |
||
174 | public function rename($from, $to) { |
||
177 | |||
178 | /** |
||
179 | * Upload a local file |
||
180 | * |
||
181 | * @param string $source local file |
||
182 | 226 | * @param string $target remove file |
|
183 | 226 | * @return bool |
|
184 | 226 | * |
|
185 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
186 | 204 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
|
187 | 204 | */ |
|
188 | 102 | public function put($source, $target) { |
|
198 | |||
199 | /** |
||
200 | * Download a remote file |
||
201 | * |
||
202 | * @param string $source remove file |
||
203 | * @param string $target local file |
||
204 | * @return bool |
||
205 | 88 | * |
|
206 | 88 | * @throws \Icewind\SMB\Exception\NotFoundException |
|
207 | 18 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
|
208 | * @throws \Icewind\SMB\Exception\InvalidPathException |
||
209 | 70 | * @throws \Icewind\SMB\Exception\InvalidResourceException |
|
210 | 70 | */ |
|
211 | 2 | public function get($source, $target) { |
|
238 | |||
239 | /** |
||
240 | * Open a readable stream to a remote file |
||
241 | * |
||
242 | 58 | * @param string $source |
|
243 | 58 | * @return resource a read only stream with the contents of the remote file |
|
244 | 40 | * |
|
245 | 40 | * @throws \Icewind\SMB\Exception\NotFoundException |
|
246 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
247 | */ |
||
248 | public function read($source) { |
||
253 | |||
254 | /** |
||
255 | * Open a writeable stream to a remote file |
||
256 | * Note: This method will truncate the file to 0bytes first |
||
257 | 58 | * |
|
258 | 58 | * @param string $source |
|
259 | 40 | * @return resource a writeable stream |
|
260 | 40 | * |
|
261 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
262 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
263 | */ |
||
264 | public function write($source) { |
||
269 | |||
270 | 28 | /** |
|
271 | 28 | * Open a writeable stream and set the cursor to the end of the stream |
|
272 | * |
||
273 | * @param string $source |
||
274 | * @return resource a writeable stream |
||
275 | * |
||
276 | * @throws \Icewind\SMB\Exception\NotFoundException |
||
277 | * @throws \Icewind\SMB\Exception\InvalidTypeException |
||
278 | */ |
||
279 | public function append($source) { |
||
284 | 16 | ||
285 | 8 | /** |
|
286 | * Get extended attributes for the path |
||
287 | 16 | * |
|
288 | * @param string $path |
||
289 | * @param string $attribute attribute to get the info |
||
290 | * @return string the attribute value |
||
291 | */ |
||
292 | public function getAttribute($path, $attribute) { |
||
295 | 16 | ||
296 | 16 | /** |
|
297 | * Set extended attributes for the given path |
||
298 | * |
||
299 | * @param string $path |
||
300 | * @param string $attribute attribute to get the info |
||
301 | * @param string|int $value |
||
302 | * @return mixed the attribute value |
||
303 | */ |
||
304 | public function setAttribute($path, $attribute, $value) { |
||
311 | |||
312 | /** |
||
313 | 510 | * Set DOS comaptible node mode |
|
314 | 510 | * |
|
315 | 510 | * @param string $path |
|
316 | * @param int $mode a combination of FileInfo::MODE_READONLY, FileInfo::MODE_ARCHIVE, FileInfo::MODE_SYSTEM and FileInfo::MODE_HIDDEN, FileInfo::NORMAL |
||
317 | * @return mixed |
||
318 | */ |
||
319 | public function setMode($path, $mode) { |
||
322 | |||
323 | /** |
||
324 | * Start smb notify listener |
||
325 | * Note: This is a blocking call |
||
326 | * |
||
327 | * @param string $path |
||
328 | * @return INotifyHandler |
||
329 | */ |
||
330 | public function notify($path) { |
||
339 | |||
340 | public function __destruct() { |
||
343 | } |
||
344 |
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: