Skip to content

Commit 8c3dc13

Browse files
committed
Doc and CS fixes (suggested by Scrutinizer-CI).
1 parent f938b58 commit 8c3dc13

File tree

9 files changed

+96
-80
lines changed

9 files changed

+96
-80
lines changed

src/PEAR2/Net/RouterOS/Client.php

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,25 @@ class Client
105105
* Creates a new instance of a RouterOS API client with the specified
106106
* settings.
107107
*
108-
* @param string $host Hostname (IP or domain) of the RouterOS server.
109-
* @param string $username The RouterOS username.
110-
* @param string $password The RouterOS password.
111-
* @param int|null $port The port on which the RouterOS server provides
112-
* the API service. You can also specify NULL, in which case the port
113-
* will automatically be chosen between 8728 and 8729, depending on the
114-
* value of $crypto.
115-
* @param bool $persist Whether or not the connection should be a
108+
* @param string $host Hostname (IP or domain) of RouterOS.
109+
* @param string $username The RouterOS username.
110+
* @param string $password The RouterOS password.
111+
* @param int|null $port The port on which the RouterOS host
112+
* provides the API service. You can also specify NULL, in which case
113+
* the port will automatically be chosen between 8728 and 8729,
114+
* depending on the value of $crypto.
115+
* @param bool $persist Whether or not the connection should be a
116116
* persistent one.
117-
* @param float $timeout The timeout for the connection.
118-
* @param string $crypto The encryption for this connection. Must be one
119-
* of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_* constants. Off
120-
* by default. RouterOS currently supports only TLS, but the setting is
121-
* provided in this fashion for forward compatibility's sake. And for
122-
* the sake of simplicity, if you specify an encryption, don't specify a
123-
* context and your default context uses the value "DEFAULT" for
124-
* ciphers, "ADH" will be automatically added to the list of ciphers.
125-
* @param resource $context A context for the socket.
117+
* @param double|null $timeout The timeout for the connection.
118+
* @param string $crypto The encryption for this connection.
119+
* Must be one of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_*
120+
* constants. Off by default. RouterOS currently supports only TLS, but
121+
* the setting is provided in this fashion for forward compatibility's
122+
* sake. And for the sake of simplicity, if you specify an encryption,
123+
* don't specify a context and your default context uses the value
124+
* "DEFAULT" for ciphers, "ADH" will be automatically added to the list
125+
* of ciphers.
126+
* @param resource|null $context A context for the socket.
126127
*
127128
* @see sendSync()
128129
* @see sendAsync()
@@ -350,14 +351,15 @@ public function getCharset($charsetType)
350351
/**
351352
* Sends a request and waits for responses.
352353
*
353-
* @param Request $request The request to send.
354-
* @param callback $callback Optional. A function that is to be executed
355-
* when new responses for this request are available. The callback takes
356-
* two parameters. The {@link Response} object as the first, and the
357-
* {@link Client} object as the second one. If the function returns
358-
* TRUE, the request is canceled. Note that the callback may be executed
359-
* one last time after that with a response that notifies about the
360-
* canceling.
354+
* @param Request $request The request to send.
355+
* @param callback|null $callback Optional. A function that is to be
356+
* executed when new responses for this request are available.
357+
* The callback takes two parameters. The {@link Response} object as
358+
* the first, and the {@link Client} object as the second one. If the
359+
* callback returns TRUE, the request is canceled. Note that the
360+
* callback may be executed at least two times after that. Once with a
361+
* {@link Response::TYPE_ERROR} response that notifies about the
362+
* canceling, plus the {@link Response::TYPE_FINAL} response.
361363
*
362364
* @return $this The client object.
363365
*

src/PEAR2/Net/RouterOS/Communicator.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,25 @@ class Communicator
9191
/**
9292
* Creates a new connection with the specified options.
9393
*
94-
* @param string $host Hostname (IP or domain) of the RouterOS server.
95-
* @param int|null $port The port on which the RouterOS server provides
96-
* the API service. You can also specify NULL, in which case the port
97-
* will automatically be chosen between 8728 and 8729, depending on the
98-
* value of $crypto.
99-
* @param bool $persist Whether or not the connection should be a
94+
* @param string $host Hostname (IP or domain) of RouterOS.
95+
* @param int|null $port The port on which the RouterOS host
96+
* provides the API service. You can also specify NULL, in which case
97+
* the port will automatically be chosen between 8728 and 8729,
98+
* depending on the value of $crypto.
99+
* @param bool $persist Whether or not the connection should be a
100100
* persistent one.
101-
* @param float $timeout The timeout for the connection.
102-
* @param string $key A string that uniquely identifies the
101+
* @param double|null $timeout The timeout for the connection.
102+
* @param string $key A string that uniquely identifies the
103103
* connection.
104-
* @param string $crypto The encryption for this connection. Must be one
105-
* of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_* constants. Off
106-
* by default. RouterOS currently supports only TLS, but the setting is
107-
* provided in this fashion for forward compatibility's sake. And for
108-
* the sake of simplicity, if you specify an encryption, don't specify a
109-
* context and your default context uses the value "DEFAULT" for
110-
* ciphers, "ADH" will be automatically added to the list of ciphers.
111-
* @param resource $context A context for the socket.
104+
* @param string $crypto The encryption for this connection.
105+
* Must be one of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_*
106+
* constants. Off by default. RouterOS currently supports only TLS, but
107+
* the setting is provided in this fashion for forward compatibility's
108+
* sake. And for the sake of simplicity, if you specify an encryption,
109+
* don't specify a context and your default context uses the value
110+
* "DEFAULT" for ciphers, "ADH" will be automatically added to the list
111+
* of ciphers.
112+
* @param resource|null $context A context for the socket.
112113
*
113114
* @see sendWord()
114115
*/
@@ -176,8 +177,8 @@ public function __construct(
176177
* function. Depending on the argument given, one of the other functions in
177178
* the class is invoked and its returned value is returned by this function.
178179
*
179-
* @param string $string A string of the word to send, or NULL to get the
180-
* next word as a string.
180+
* @param string|null $string A string of the word to send, or NULL to get
181+
* the next word as a string.
181182
*
182183
* @return int|string If a string is provided, returns the number of bytes
183184
* sent, otherwise returns the next word as a string.

src/PEAR2/Net/RouterOS/LengthException.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
*/
2626
use LengthException as L;
2727

28+
/**
29+
* Used in $previous
30+
*/
31+
use Exception as E;
32+
2833
/**
2934
* Exception thrown when there is a problem with a word's length.
3035
*
@@ -42,23 +47,23 @@ class LengthException extends L implements Exception
4247
const CODE_BEYOND_SHEME = 1301;
4348

4449
/**
45-
* @var mixed The problematic length.
50+
* @var int|double|null The problematic length.
4651
*/
4752
private $_length;
4853

4954
/**
5055
* Creates a new LengthException.
5156
*
52-
* @param string $message The Exception message to throw.
53-
* @param int $code The Exception code.
54-
* @param \Exception $previous The previous exception used for the exception
55-
* chaining.
56-
* @param number $length The length.
57+
* @param string $message The Exception message to throw.
58+
* @param int $code The Exception code.
59+
* @param E|null $previous The previous exception used for the
60+
* exception chaining.
61+
* @param int|double|null $length The length.
5762
*/
5863
public function __construct(
5964
$message,
6065
$code = 0,
61-
$previous = null,
66+
E $previous = null,
6267
$length = null
6368
) {
6469
parent::__construct($message, $code, $previous);
@@ -68,7 +73,7 @@ public function __construct(
6873
/**
6974
* Gets the length.
7075
*
71-
* @return number The length.
76+
* @return int|double|null The length.
7277
*/
7378
public function getLength()
7479
{

src/PEAR2/Net/RouterOS/Message.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ abstract class Message implements IteratorAggregate, Countable
6666
* function. Depending on the argument given, one of the other functions in
6767
* the class is invoked and its returned value is returned by this function.
6868
*
69-
* @param string $name The name of an attribute to get the value of, or NULL
70-
* to get the tag.
69+
* @param string|null $name The name of an attribute to get the value of,
70+
* or NULL to get the tag.
7171
*
7272
* @return string|resource The value of the specified attribute,
7373
* or the tag if NULL is provided.

src/PEAR2/Net/RouterOS/NotSupportedException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ class NotSupportedException extends E implements Exception
5252
/**
5353
* Creates a new NotSupportedException.
5454
*
55-
* @param string $message The Exception message to throw.
56-
* @param int $code The Exception code.
57-
* @param \Exception $previous The previous exception used for the exception
55+
* @param string $message The Exception message to throw.
56+
* @param int $code The Exception code.
57+
* @param E|null $previous The previous exception used for the exception
5858
* chaining.
59-
* @param mixed $value The unsupported value.
59+
* @param mixed $value The unsupported value.
6060
*/
6161
public function __construct(
6262
$message,
6363
$code = 0,
64-
$previous = null,
64+
E $previous = null,
6565
$value = null
6666
) {
6767
parent::__construct($message, $code, $previous);

src/PEAR2/Net/RouterOS/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Query
7474
* This class is not to be instantiated normally, but by static methods
7575
* instead. Use {@link static::where()} to create an instance of it.
7676
*/
77-
private function __construct()
77+
protected function __construct()
7878
{
7979

8080
}

src/PEAR2/Net/RouterOS/Request.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class Request extends Message
5050
/**
5151
* Creates a request to send to RouterOS.
5252
*
53-
* @param string $command The command to send. Can also contain arguments
54-
* expressed in a shell-like syntax.
55-
* @param Query $query A query to associate with the request.
56-
* @param string $tag The tag for the request.
53+
* @param string $command The command to send.
54+
* Can also contain arguments expressed in a shell-like syntax.
55+
* @param Query|null $query A query to associate with the request.
56+
* @param string|null $tag The tag for the request.
5757
*
5858
* @see setCommand()
5959
* @see setArgument()
@@ -177,8 +177,8 @@ public function getCommand()
177177
/**
178178
* Sets the query to send with the command.
179179
*
180-
* @param Query $query The query to be set. Setting NULL will remove the
181-
* currently associated query.
180+
* @param Query|null $query The query to be set.
181+
* Setting NULL will remove the currently associated query.
182182
*
183183
* @return $this The request object.
184184
*
@@ -193,7 +193,7 @@ public function setQuery(Query $query = null)
193193
/**
194194
* Gets the currently associated query
195195
*
196-
* @return Query The currently associated query.
196+
* @return Query|null The currently associated query.
197197
*
198198
* @see setQuery()
199199
*/
@@ -208,7 +208,7 @@ public function getQuery()
208208
* Sets the tag to associate the request with. Setting NULL erases the
209209
* currently set tag.
210210
*
211-
* @param string $tag The tag to set.
211+
* @param string|null $tag The tag to set.
212212
*
213213
* @return $this The request object.
214214
*
@@ -269,8 +269,8 @@ public function removeAllArguments()
269269
/**
270270
* Sends a request over a communicator.
271271
*
272-
* @param Communicator $com The communicator to send the request over.
273-
* @param Registry $reg An optional registry to sync the request with.
272+
* @param Communicator $com The communicator to send the request over.
273+
* @param Registry|null $reg An optional registry to sync the request with.
274274
*
275275
* @return int The number of bytes sent.
276276
*

src/PEAR2/Net/RouterOS/Response.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ class Response extends Message
7676
/**
7777
* Extracts a new response from a communicator.
7878
*
79-
* @param Communicator $com The communicator from which to extract
79+
* @param Communicator $com The communicator from which to extract
8080
* the new response.
81-
* @param bool $asStream Whether to populate the argument values
81+
* @param bool $asStream Whether to populate the argument values
8282
* with streams instead of strings.
83-
* @param int $sTimeout If a response is not immediately
83+
* @param int $sTimeout If a response is not immediately
8484
* available, wait this many seconds. If NULL, wait indefinitely.
85-
* @param int $usTimeout Microseconds to add to the waiting time.
86-
* @param Registry $reg An optional registry to sync the
85+
* @param int|null $usTimeout Microseconds to add to the waiting time.
86+
* @param Registry|null $reg An optional registry to sync the
8787
* response with.
8888
*
8989
* @see getType()
@@ -154,7 +154,7 @@ public function __construct(
154154
* available, wait this many seconds. If NULL, wait indefinitely.
155155
* Note that if an empty sentence is received, the timeout will be
156156
* reset for another sentence receiving.
157-
* @param int $usTimeout Microseconds to add to the waiting time.
157+
* @param int|null $usTimeout Microseconds to add to the waiting time.
158158
*
159159
* @return void
160160
*/

src/PEAR2/Net/RouterOS/UnexpectedValueException.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@
2020
*/
2121
namespace PEAR2\Net\RouterOS;
2222

23+
/**
24+
* The base for this exception.
25+
*/
2326
use UnexpectedValueException as U;
2427

28+
/**
29+
* Used in $previous.
30+
*/
31+
use Exception as E;
32+
2533
/**
2634
* Exception thrown when encountering an invalid value in a function argument.
2735
*
@@ -45,16 +53,16 @@ class UnexpectedValueException extends U implements Exception
4553
/**
4654
* Creates a new UnexpectedValueException.
4755
*
48-
* @param string $message The Exception message to throw.
49-
* @param int $code The Exception code.
50-
* @param \Exception $previous The previous exception used for the exception
56+
* @param string $message The Exception message to throw.
57+
* @param int $code The Exception code.
58+
* @param E|null $previous The previous exception used for the exception
5159
* chaining.
52-
* @param mixed $value The unexpected value.
60+
* @param mixed $value The unexpected value.
5361
*/
5462
public function __construct(
5563
$message,
5664
$code = 0,
57-
$previous = null,
65+
E $previous = null,
5866
$value = null
5967
) {
6068
parent::__construct($message, $code, $previous);

0 commit comments

Comments
 (0)