Skip to content

Commit

Permalink
- phpDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 15, 2008
1 parent 8f0da10 commit 3ecf0d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ftp.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
class Ftp
{
/**#@+ FTP constant alias */
const ASCII = FTP_ASCII;
const TEXT = FTP_TEXT;
const BINARY = FTP_BINARY;
Expand All @@ -21,6 +22,7 @@ class Ftp
const FAILED = FTP_FAILED;
const FINISHED = FTP_FINISHED;
const MOREDATA = FTP_MOREDATA;
/**#@-*/

private static $aliases = array(
'sslconnect' => 'ssl_connect',
Expand All @@ -46,6 +48,11 @@ class Ftp

/**
* Magic method (do not call directly).
* @param string method name
* @param array arguments
* @return mixed
* @throws Exception
* @throws FtpException
*/
public function __call($name, $args)
{
Expand All @@ -71,8 +78,8 @@ public function __call($name, $args)
throw new FtpException("Not connected to FTP server. Call connect() or ssl_connect() first.");

} else {
if ($func === 'ftp_login') {
$this->state['login'] = $args;
if ($func === 'ftp_login' || $func === 'ftp_pasv') {
$this->state[$name] = $args;
}

array_unshift($args, $this->resource);
Expand Down Expand Up @@ -117,7 +124,7 @@ public function _errorHandler($code, $message)
*/
public function reconnect()
{
@ftp_close($this->resource);
@ftp_close($this->resource); // intentionally @
foreach ($this->state as $name => $args) {
call_user_func_array(array($this, $name), $args);
}
Expand Down Expand Up @@ -156,7 +163,7 @@ public function isDir($dir)


/**
* Recursive creates directory.
* Recursive creates directories.
* @param string
* @return void
*/
Expand Down
6 changes: 6 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ Ftp throws exception if operation failed. So you can simply do following:
echo 'Error: ', $e->getMessage();
}

On the other hand, if you'd like the possible exception quietly catch, call methods with the prefix 'try':

$ftp->tryDelete($destination_file);

When the connection is accidentally interrupted, you can re-establish it using method $ftp->reconnect().


Files
-----
Expand Down

0 comments on commit 3ecf0d8

Please sign in to comment.