Skip to content

Commit b515816

Browse files
author
AmraniCh
committed
Upgraded the code base to PHP '^7.4'
1 parent 5f843d5 commit b515816

File tree

7 files changed

+40
-294
lines changed

7 files changed

+40
-294
lines changed

src/Command/FtpCommand.php

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,35 @@
2323
*/
2424
class FtpCommand
2525
{
26-
/** @var ConnectionInterface */
27-
protected $connection;
26+
protected ConnectionInterface $connection;
27+
protected FtpWrapper $wrapper;
2828

29-
/** @var FtpWrapper */
30-
protected $wrapper;
31-
32-
/**
33-
* FtpCommand constructor.
34-
*
35-
* @param ConnectionInterface $connection
36-
*/
3729
public function __construct(ConnectionInterface $connection)
3830
{
3931
$this->connection = $connection;
4032
$this->wrapper = new FtpWrapper($connection);
4133
}
4234

43-
/**
44-
* @return ConnectionInterface
45-
*/
4635
public function getConnection() : ConnectionInterface
4736
{
4837
return $this->connection;
4938
}
5039

5140
/**
52-
* @param ConnectionInterface $connection
53-
*
5441
* @since 1.5.3
55-
*
56-
* @return void
5742
*/
5843
public function setConnection(ConnectionInterface $connection) : void
5944
{
6045
$this->connection = $connection;
6146
}
6247

63-
/**
64-
* @param FtpWrapper $wrapper
65-
*
66-
* @return void
67-
*/
6848
public function setWrapper(FtpWrapper $wrapper) : void
6949
{
7050
$this->wrapper = $wrapper;
7151
}
7252

7353
/**
7454
* @since 1.5.3
75-
*
76-
* @return FtpWrapper
7755
*/
7856
public function getWrapper() : FtpWrapper
7957
{
@@ -127,10 +105,6 @@ public function site(string $command) : bool
127105
*
128106
* Note! Not all FTP servers support this command.
129107
*
130-
* @param string $command
131-
*
132-
* @return bool
133-
*
134108
* @throws CommandException
135109
*/
136110
public function exec(string $command) : bool
@@ -165,11 +139,6 @@ public function supportedSiteCommands() : array
165139
return array_map('ltrim', $response['body']);
166140
}
167141

168-
/**
169-
* @param array $response
170-
*
171-
* @return array
172-
*/
173142
protected function parseRawResponse(array $response) : array
174143
{
175144
$code = $message = $body = $endMessage = null;

src/Config/FtpConfig.php

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,34 @@
2323
*/
2424
class FtpConfig
2525
{
26-
/** @var ConnectionInterface */
27-
protected $connection;
26+
protected ConnectionInterface $connection;
27+
protected FtpWrapper $wrapper;
2828

29-
/** @var FtpWrapper */
30-
protected $wrapper;
31-
32-
/**
33-
* FtpConfig constructor.
34-
*
35-
* @param ConnectionInterface $connection
36-
*/
3729
public function __construct(ConnectionInterface $connection)
3830
{
3931
$this->connection = $connection;
4032
$this->wrapper = new FtpWrapper($connection);
4133
}
4234

43-
/**
44-
* @return ConnectionInterface
45-
*/
4635
public function getConnection() : ConnectionInterface
4736
{
4837
return $this->connection;
4938
}
5039

5140
/**
52-
* @param ConnectionInterface $connection
53-
*
5441
* @since 1.5.3
55-
*
56-
* @return void
5742
*/
5843
public function setConnection(ConnectionInterface $connection) : void
5944
{
6045
$this->connection = $connection;
6146
}
6247

63-
/**
64-
* @param FtpWrapper $wrapper
65-
*
66-
* @return void
67-
*/
6848
public function setWrapper(FtpWrapper $wrapper) : void
6949
{
7050
$this->wrapper = $wrapper;
7151
}
7252

7353
/**
74-
* @return FtpWrapper
75-
*
7654
* @since 1.5.3
7755
*/
7856
public function getWrapper() : FtpWrapper
@@ -83,8 +61,6 @@ public function getWrapper() : FtpWrapper
8361
/**
8462
* Turn the passive mode on or off.
8563
*
86-
* @param bool $value
87-
*
8864
* @return bool Returns true in success, if not an exception throws.
8965
*
9066
* @throws ConfigException
@@ -110,8 +86,8 @@ public function setPassive(bool $value) : bool
11086
*/
11187
public function setTimeout(int $value) : bool
11288
{
113-
if (!is_int($value) || $value < 0) {
114-
throw new ConfigException("[{$value}] Timeout option value must be of type integer and greater than 0.");
89+
if ($value < 0) {
90+
throw new ConfigException("[{$value}] Timeout option value must be greater than 0.");
11591
}
11692

11793
if (!$this->wrapper->set_option(FtpWrapper::TIMEOUT_SEC, $value)) {
@@ -123,20 +99,14 @@ public function setTimeout(int $value) : bool
12399
}
124100

125101
/**
126-
* Specifies if the IP address returned via the PASV command will be used to open the data channel.
127-
*
128-
* @param bool $value
102+
* Specifies if the IP address returned via the 'PASV' command will be used to open the data channel.
129103
*
130104
* @return bool Returns true in success, if not an exception throws.
131105
*
132106
* @throws ConfigException
133107
*/
134108
public function usePassiveAddress(bool $value) : bool
135109
{
136-
if (!is_bool($value)) {
137-
throw new ConfigException("[{$value}] usePassiveAddress option value must be of type boolean.");
138-
}
139-
140110
if (!$this->wrapper->set_option(FtpWrapper::USEPASVADDRESS, $value)) {
141111
throw new ConfigException($this->wrapper->getErrorMessage()
142112
?: "Unable to set usePassiveAddress runtime option.");
@@ -148,18 +118,12 @@ public function usePassiveAddress(bool $value) : bool
148118
/**
149119
* Sets the autoSeek option on/off.
150120
*
151-
* @param bool $value
152-
*
153121
* @return bool Returns true in success, if not an exception throws.
154122
*
155123
* @throws ConfigException
156124
*/
157125
public function setAutoSeek(bool $value) : bool
158126
{
159-
if (!is_bool($value)) {
160-
throw new ConfigException("[{$value}] AutoSeek option value must be of type boolean.");
161-
}
162-
163127
if (!$this->wrapper->set_option(FtpWrapper::AUTOSEEK, $value)) {
164128
throw new ConfigException($this->wrapper->getErrorMessage()
165129
?: "Unable to set AutoSeek runtime option.");
@@ -171,8 +135,6 @@ public function setAutoSeek(bool $value) : bool
171135
/**
172136
* Gets the timeout option value.
173137
*
174-
* @return int
175-
*
176138
* @throws ConfigException
177139
*/
178140
public function getTimeout() : int
@@ -187,19 +149,15 @@ public function getTimeout() : int
187149

188150
/**
189151
* Checks if the autoSeek option enabled or not.
190-
*
191-
* @return bool
192152
*/
193153
public function isAutoSeek() : bool
194154
{
195155
return $this->wrapper->get_option(FtpWrapper::AUTOSEEK);
196156
}
197157

198158
/**
199-
* Checks if the passive address returned in the PASV response
159+
* Checks if the passive address returned to the 'PASV' response
200160
* is used by the control channel or not.
201-
*
202-
* @return bool
203161
*/
204162
public function isUsePassiveAddress() : bool
205163
{

src/Connection/Connection.php

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,17 @@
2222
*/
2323
abstract class Connection implements ConnectionInterface
2424
{
25-
/** @var FtpWrapper */
26-
protected $wrapper;
25+
protected FtpWrapper $wrapper;
2726

2827
/** @var resource */
2928
protected $stream;
3029

31-
/** @var string */
32-
protected $host;
33-
34-
/** @var int */
35-
protected $port;
36-
37-
/** @var int */
38-
protected $timeout;
39-
40-
/** @var string */
41-
protected $username;
42-
43-
/* @var string */
44-
protected $password;
45-
46-
/** @var bool */
47-
protected $isConnected;
30+
protected string $host;
31+
protected int $port;
32+
protected int $timeout;
33+
protected string $username;
34+
protected string $password;
35+
protected bool $isConnected;
4836

4937
/**
5038
* Prepares an FTP connection.
@@ -68,20 +56,13 @@ public function __construct(string $host, string $username, string $password, in
6856
$this->wrapper = new FtpWrapper($this);
6957
}
7058

71-
/**
72-
* @param FtpWrapper $wrapper
73-
*
74-
* @return void
75-
*/
7659
public function setWrapper(FtpWrapper $wrapper) : void
7760
{
7861
$this->wrapper = $wrapper;
7962
}
8063

8164
/**
8265
* @since 1.5.3
83-
*
84-
* @return FtpWrapper
8566
*/
8667
public function getWrapper() : FtpWrapper
8768
{
@@ -102,49 +83,31 @@ public function getStream()
10283
return $this->stream;
10384
}
10485

105-
/**
106-
* @inheritDoc
107-
*/
10886
public function getHost() : string
10987
{
11088
return $this->host;
11189
}
11290

113-
/**
114-
* @inheritDoc
115-
*/
11691
public function getPort() : int
11792
{
11893
return $this->port;
11994
}
12095

121-
/**
122-
* @inheritDoc
123-
*/
12496
public function getTimeout() : int
12597
{
12698
return $this->timeout;
12799
}
128100

129-
/**
130-
* @inheritDoc
131-
*/
132101
public function getUsername() : string
133102
{
134103
return $this->username;
135104
}
136105

137-
/**
138-
* @inheritDoc
139-
*/
140106
public function getPassword() : string
141107
{
142108
return $this->password;
143109
}
144110

145-
/**
146-
* @inheritDoc
147-
*/
148111
public function isConnected() : bool
149112
{
150113
return $this->isConnected;

src/Connection/ConnectionInterface.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@ interface ConnectionInterface
2121
{
2222
/**
2323
* Opens the FTP connection.
24-
*
25-
* @return bool
2624
*/
2725
public function open() : bool;
2826

2927
/**
3028
* Closes the FTP connection.
31-
*
32-
* @return bool
3329
*/
3430
public function close() : bool;
3531

@@ -38,33 +34,15 @@ public function close() : bool;
3834
*/
3935
public function getStream();
4036

41-
/**
42-
* @return string
43-
*/
4437
public function getHost() : string;
4538

46-
/**
47-
* @return int
48-
*/
4939
public function getPort() : int;
5040

51-
/**
52-
* @return int
53-
*/
5441
public function getTimeout() : int;
5542

56-
/**
57-
* @return string
58-
*/
5943
public function getUsername() : string;
6044

61-
/**
62-
* @return string
63-
*/
6445
public function getPassword() : string;
6546

66-
/**
67-
* @return bool
68-
*/
6947
public function isConnected() : bool;
7048
}

src/Connection/FtpSSLConnection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ protected function connect() : void
5454
?: 'SSL connection failed to the FTP server.');
5555
}
5656

57-
$this->isSecure = true;
58-
5957
$this->wrapper->setConnection($this);
6058
}
6159
}

0 commit comments

Comments
 (0)