Skip to content

Commit 2f1e8f7

Browse files
author
Igor Chepurnoy
committed
fix phpstorm issues
1 parent b3f0c7b commit 2f1e8f7

File tree

6 files changed

+108
-64
lines changed

6 files changed

+108
-64
lines changed

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ignore all test and documentation for archive
2+
/.gitattributes export-ignore
3+
/.gitignore export-ignore
4+
/.scrutinizer.yml export-ignore
5+
/.travis.yml export-ignore
6+
/phpunit.xml.dist export-ignore
7+
/tests export-ignore
8+
/docs export-ignore

.gitignore

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
vendor/
2-
composer.lock
1+
# phpstorm project files
2+
.idea
3+
4+
# netbeans project files
5+
nbproject
6+
7+
# zend studio for eclipse project files
8+
.buildpath
9+
.project
10+
.settings
11+
12+
# windows thumbnail cache
13+
Thumbs.db
14+
15+
# composer vendor dir
16+
/vendor
17+
18+
/composer.lock
19+
20+
# composer itself is not needed
21+
composer.phar
22+
23+
# Mac DS_Store Files
24+
.DS_Store
25+
26+
# phpunit itself is not needed
27+
phpunit.phar
28+
# local phpunit config
29+
/phpunit.xml
30+
31+
# local tests configuration
32+
/tests/data/config.local.php
33+
34+
# runtime cache
35+
/tests/runtime

FtpClient.php

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ class FtpClient implements \Countable
4343
* @var resource
4444
*/
4545
protected $conn;
46+
4647
/**
4748
* PHP FTP functions wrapper
4849
*
49-
* @var Functions
50+
* @var FtpWrapper
5051
*/
5152
private $ftp;
5253

@@ -62,9 +63,11 @@ public function __construct($connection = null)
6263
if (!extension_loaded('ftp')) {
6364
throw new FtpException('FTP extension is not loaded!');
6465
}
66+
6567
if ($connection) {
6668
$this->conn = $connection;
6769
}
70+
6871
$this->setWrapper(new FtpWrapper($this->conn));
6972
}
7073

@@ -84,8 +87,8 @@ public function __destruct()
8487
* Wrap the FTP PHP functions to call as method of FtpClient object.
8588
* The connection is automaticaly passed to the FTP PHP functions.
8689
*
87-
* @param $method
88-
* @param array $arguments
90+
* @param $method
91+
* @param array $arguments
8992
*
9093
* @internal param string $function
9194
*
@@ -99,8 +102,8 @@ public function __call($method, array $arguments)
99102
/**
100103
* Overwrites the PHP limit
101104
*
102-
* @param string|null $memory The memory limit, if null is not modified
103-
* @param int $time_limit The max execution time, unlimited by default
105+
* @param string|null $memory The memory limit, if null is not modified
106+
* @param int $time_limit The max execution time, unlimited by default
104107
*
105108
* @return FtpClient
106109
*/
@@ -129,9 +132,9 @@ public function help()
129132
* Open a FTP connection
130133
*
131134
* @param string $host
132-
* @param bool $ssl
133-
* @param int $port
134-
* @param int $timeout
135+
* @param bool $ssl
136+
* @param int $port
137+
* @param int $timeout
135138
*
136139
* @return FTPClient
137140
*
@@ -154,9 +157,9 @@ public function connect($host, $ssl = false, $port = 21, $timeout = 90)
154157
/**
155158
* Download files
156159
*
157-
* @param string $source_directory
158-
* @param string $target_directory
159-
* @param int $mode
160+
* @param string $source_directory
161+
* @param string $target_directory
162+
* @param int $mode
160163
*
161164
* @return FtpClient
162165
*/
@@ -226,7 +229,7 @@ public function login($username = 'anonymous', $password = '')
226229
* Return -1 on error
227230
*
228231
* @param string $remoteFile
229-
* @param null $format
232+
* @param null $format
230233
*
231234
* @return int
232235
*/
@@ -260,11 +263,11 @@ public function up()
260263
/**
261264
* Returns a list of files in the given directory
262265
*
263-
* @param string $directory The directory, by default is "." the current directory
264-
* @param bool $recursive
265-
* @param callable|string $filter A callable to filter the result, by default is asort() PHP function.
266-
* The result is passed in array argument, must take the argument by reference !
267-
* The callable should proceed with the reference array because is the behavior of several PHP sorting functions (by reference ensure directly the compatibility with all PHP sorting functions)
266+
* @param string $directory The directory, by default is "." the current directory
267+
* @param bool $recursive
268+
* @param callable|string $filter A callable to filter the result, by default is asort() PHP function.
269+
* The result is passed in array argument, must take the argument by reference!
270+
* The callable should proceed with the reference array because is the behavior of several PHP sorting functions (by reference ensure directly the compatibility with all PHP sorting functions)
268271
*
269272
* @throws FtpException
270273
*
@@ -341,25 +344,28 @@ public function nlist($directory = '.', $recursive = false, $filter = 'sort')
341344
* @see FtpClient::put()
342345
* @see FtpClient::putAll()
343346
*
344-
* @param string $directory The directory
345-
* @param bool $recursive
347+
* @param string $directory The directory
348+
* @param bool $recursive
346349
*
347-
* @return array
350+
* @return string|false
348351
*/
349352
public function mkdir($directory, $recursive = false)
350353
{
351354
if (!$recursive or $this->isDir($directory)) {
352355
return $this->ftp->mkdir($directory);
353356
}
357+
354358
$result = false;
355359
$pwd = $this->ftp->pwd();
356360
$parts = explode('/', $directory);
361+
357362
foreach ($parts as $part) {
358363
if (!@$this->ftp->chdir($part)) {
359364
$result = $this->ftp->mkdir($part);
360365
$this->ftp->chdir($part);
361366
}
362367
}
368+
363369
$this->ftp->chdir($pwd);
364370

365371
return $result;
@@ -373,8 +379,8 @@ public function mkdir($directory, $recursive = false)
373379
* @see FtpClient::remove()
374380
* @see FtpClient::delete()
375381
*
376-
* @param string $directory
377-
* @param bool $recursive Forces deletion if the directory is not empty
382+
* @param string $directory
383+
* @param bool $recursive Forces deletion if the directory is not empty
378384
*
379385
* @return bool
380386
*
@@ -400,7 +406,7 @@ public function rmdir($directory, $recursive = true)
400406
* @see FtpClient::delete()
401407
* @see FtpClient::rmdir()
402408
*
403-
* @param string $directory
409+
* @param string $directory
404410
*
405411
* @return bool
406412
*/
@@ -424,8 +430,8 @@ public function cleanDir($directory)
424430
* @see FtpClient::cleanDir()
425431
* @see FtpClient::delete()
426432
*
427-
* @param string $path The path of the file or directory to remove
428-
* @param bool $recursive Is effective only if $path is a directory, {@see FtpClient::rmdir()}
433+
* @param string $path The path of the file or directory to remove
434+
* @param bool $recursive Is effective only if $path is a directory, {@see FtpClient::rmdir()}
429435
*
430436
* @return bool
431437
*/
@@ -470,7 +476,7 @@ public function isDir($directory)
470476
/**
471477
* Check if a directory is empty
472478
*
473-
* @param string $directory
479+
* @param string $directory
474480
*
475481
* @return bool
476482
*/
@@ -487,8 +493,8 @@ public function isEmpty($directory)
487493
* @see FtpClient::parseRawList()
488494
* @see FtpClient::dirSize()
489495
*
490-
* @param string $directory
491-
* @param bool $recursive
496+
* @param string $directory
497+
* @param bool $recursive
492498
*
493499
* @return array
494500
*/
@@ -500,10 +506,10 @@ public function scanDir($directory = '.', $recursive = false)
500506
/**
501507
* Returns the total size of the given directory in bytes
502508
*
503-
* @param string $directory The directory, by default is the current directory
504-
* @param bool $recursive true by default
509+
* @param string $directory The directory, by default is the current directory
510+
* @param bool $recursive true by default
505511
*
506-
* @return int The size in bytes
512+
* @return int The size in bytes
507513
*/
508514
public function dirSize($directory = '.', $recursive = true)
509515
{
@@ -519,9 +525,9 @@ public function dirSize($directory = '.', $recursive = true)
519525
/**
520526
* Count the items (file, directory, link, unknown)
521527
*
522-
* @param string $directory The directory, by default is the current directory
523-
* @param string|null $type The type of item to count (file, directory, link, unknown)
524-
* @param bool $recursive true by default
528+
* @param string $directory The directory, by default is the current directory
529+
* @param string|null $type The type of item to count (file, directory, link, unknown)
530+
* @param bool $recursive true by default
525531
*
526532
* @return int
527533
*/
@@ -544,8 +550,8 @@ public function count($directory = '.', $type = null, $recursive = true)
544550
/**
545551
* Uploads a file to the server from a string
546552
*
547-
* @param string $remote_file
548-
* @param string $content
553+
* @param string $remote_file
554+
* @param string $content
549555
*
550556
* @return FtpClient
551557
*
@@ -565,7 +571,7 @@ public function putFromString($remote_file, $content)
565571
/**
566572
* Uploads a file to the server
567573
*
568-
* @param string $local_file
574+
* @param string $local_file
569575
*
570576
* @return FtpClient
571577
*
@@ -586,9 +592,9 @@ public function putFromPath($local_file)
586592
/**
587593
* Upload files
588594
*
589-
* @param string $source_directory
590-
* @param string $target_directory
591-
* @param int $mode
595+
* @param string $source_directory
596+
* @param string $target_directory
597+
* @param int $mode
592598
*
593599
* @return FtpClient
594600
*/
@@ -630,8 +636,8 @@ public function putAll($source_directory, $target_directory, $mode = FTP_BINARY)
630636
* @see FtpClient::scanDir()
631637
* @see FtpClient::dirSize()
632638
*
633-
* @param string $directory The directory, by default is the current directory
634-
* @param bool $recursive
639+
* @param string $directory The directory, by default is the current directory
640+
* @param bool $recursive
635641
*
636642
* @return array
637643
*
@@ -660,7 +666,7 @@ public function rawlist($directory = '.', $recursive = false)
660666

661667
return $items;
662668
}
663-
$path = '';
669+
664670
foreach ($list as $item) {
665671
$len = strlen($item);
666672
if (!$len
@@ -699,7 +705,7 @@ public function rawlist($directory = '.', $recursive = false)
699705
* @see FtpClient::scanDir()
700706
* @see FtpClient::dirSize()
701707
*
702-
* @param array $rawlist
708+
* @param array $rawlist
703709
*
704710
* @return array
705711
*/
@@ -723,7 +729,6 @@ public function parseRawList(array $rawlist)
723729
// $chunks[8] and up contains filename (multiple elements if filename contains spaces)
724730
// up to last element or element containing '->' (if type is 'link')
725731
$target = '';
726-
$filename = '';
727732
$linkArrowElement = array_search('->', $chunks);
728733
if ($linkArrowElement !== false) {
729734
$filenameChunks = array_slice($chunks, 8, count($chunks) - $linkArrowElement - 1);
@@ -773,7 +778,7 @@ public function parseRawList(array $rawlist)
773778
* Convert raw info (drwx---r-x ...) to type (file, directory, link, unknown).
774779
* Only the first char is used for resolving.
775780
*
776-
* @param string $permission Example : drwx---r-x
781+
* @param string $permission Example : drwx---r-x
777782
*
778783
* @throws FtpException
779784
*
@@ -803,7 +808,7 @@ public function rawToType($permission)
803808
/**
804809
* Set the wrapper which forward the PHP FTP functions to use in FtpClient instance.
805810
*
806-
* @param FtpWrapper $wrapper
811+
* @param FtpWrapper $wrapper
807812
*
808813
* @return FtpClient
809814
*/

FtpException.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
namespace yii2mod\ftp;
44

55
/**
6-
* The FtpException class.
7-
* Exception thrown if an error on runtime of the FTP client occurs.
8-
*
9-
* @inheritDoc
6+
* The FtpException class. Exception thrown if an error on runtime of the FTP client occurs.
107
*/
118
class FtpException extends \Exception
129
{

0 commit comments

Comments
 (0)