Skip to content

Commit c28e378

Browse files
committed
Fixed sending of charset converted streams;
Regenerated Doxygen settings from the latest release; Doc and CS fixes (notably: Short descriptions of properties instead of "var" descriptions).
1 parent 7482a6f commit c28e378

19 files changed

+1934
-1096
lines changed

RELEASE-1.0.0b6

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Util stuff, mostly.
1515
* Script::parseValue() now recognizes dates in the "M/d/Y H:i:s" format (used across RouterOS), and turns that into a DateTime object for that time (or midnight in UTC if the time part is omitted).
1616
* Util::getAll() now throws a NotSupportedException if the arguments "follow", "follow-only" or "count-only" are used. The first two, because PHP would hang (since Client::sendSync() is used under the hood), and the last one because it's unredable in the returned output (use Util::count() instead).
1717
* Util::setMenu() can now go back to the root menu.
18+
* Util::exec() and stream valued arguments in both Util and Client no longer cause a hang when using charset conversion.
1819
* Util::get() can now accept a query as an argument for $number
1920
* Util::get() can have $valueName set to NULL (as is now by default), in which case all properties are retrieved in an array, parsed with Script::parseValueToArray().
2021
* Util::get() no longer fallbacks automatically with a "print" request for buggy versions. You may "manually" call Util::getAll() if you suspect that's an issue.

docs/doxygen.ini

Lines changed: 1670 additions & 993 deletions
Large diffs are not rendered by default.

src/PEAR2/Net/RouterOS/Client.php

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,52 @@ class Client
6464
const FILTER_ALL = 3;
6565

6666
/**
67-
* @var Communicator The communicator for this client.
67+
* The communicator for this client.
68+
*
69+
* @var Communicator
6870
*/
6971
protected $com;
7072

7173
/**
72-
* @var int The number of currently pending requests.
74+
* The number of currently pending requests.
75+
*
76+
* @var int
7377
*/
7478
protected $pendingRequestsCount = 0;
7579

7680
/**
77-
* @var array<string,Response[]> An array of responses that have not yet
78-
* been extracted or passed to a callback.
79-
* Key is the tag of the request, and the value is an array of
80-
* associated responses.
81+
* An array of responses that have not yet been extracted
82+
* or passed to a callback.
83+
*
84+
* Key is the tag of the request, and the value is an array of
85+
* associated responses.
86+
*
87+
* @var array<string,Response[]>
8188
*/
8289
protected $responseBuffer = array();
8390

8491
/**
85-
* @var array<string,callback> An array of callbacks to be executed
86-
* as responses come.
87-
* Key is the tag of the request, and the value is the callback for it.
92+
* An array of callbacks to be executed as responses come.
93+
*
94+
* Key is the tag of the request, and the value is the callback for it.
95+
*
96+
* @var array<string,callback>
8897
*/
8998
protected $callbacks = array();
9099

91100
/**
92-
* @var Registry A registry for the operations. Particularly helpful at
93-
* persistent connections.
101+
* A registry for the operations.
102+
*
103+
* Particularly helpful at persistent connections.
104+
*
105+
* @var Registry
94106
*/
95107
protected $registry = null;
96108

97109
/**
98-
* @var bool Whether to stream future responses.
110+
* Whether to stream future responses.
111+
*
112+
* @var bool
99113
*/
100114
private $_streamingResponses = false;
101115

@@ -836,7 +850,8 @@ protected function dispatchNextResponse($sTimeout = 0, $usTimeout = 0)
836850
try {
837851
$this->cancelRequest($tag);
838852
} catch (DataFlowException $e) {
839-
if ($e->getCode() !== DataFlowException::CODE_UNKNOWN_REQUEST) {
853+
if ($e->getCode() !== DataFlowException::CODE_UNKNOWN_REQUEST
854+
) {
840855
throw $e;
841856
}
842857
}

src/PEAR2/Net/RouterOS/Communicator.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,30 @@ class Communicator
6767
const CHARSET_LOCAL = 1;
6868

6969
/**
70-
* @var array<string,string|null> An array with
71-
* the default charset types as keys, and
72-
* the default charsets as values.
70+
* An array with the default charset.
71+
*
72+
* Charset types as keys, and the default charsets as values.
73+
*
74+
* @var array<string,string|null>
7375
*/
7476
protected static $defaultCharsets = array(
7577
self::CHARSET_REMOTE => null,
7678
self::CHARSET_LOCAL => null
7779
);
7880

7981
/**
80-
* @var array<string,string|null> An array with
81-
* the current charset types as keys, and
82-
* the current charsets as values.
82+
* An array with the current charset.
83+
*
84+
* Charset types as keys, and the current charsets as values.
85+
*
86+
* @var array<string,string|null>
8387
*/
8488
protected $charsets = array();
8589

8690
/**
87-
* @var T\TcpClient The transmitter for the connection.
91+
* The transmitter for the connection.
92+
*
93+
* @var T\TcpClient
8894
*/
8995
protected $trans;
9096

@@ -230,8 +236,11 @@ public static function iconvStream($inCharset, $outCharset, $stream)
230236
);
231237

232238
flock($stream, LOCK_SH);
233-
while (!feof($stream)) {
234-
$bytes += stream_copy_to_stream($stream, $result, 0xFFFFF);
239+
$reader = new T\Stream($stream, false);
240+
$writer = new T\Stream($result, false);
241+
$chunkSize = $reader->getChunk(T\Stream::DIRECTION_RECEIVE);
242+
while ($reader->isAvailable() && $reader->isDataAwaiting()) {
243+
$bytes += $writer->send(fread($stream, $chunkSize));
235244
}
236245
fseek($stream, -$bytes, SEEK_CUR);
237246
flock($stream, LOCK_UN);

src/PEAR2/Net/RouterOS/LengthException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class LengthException extends L implements Exception
4747
const CODE_BEYOND_SHEME = 1301;
4848

4949
/**
50-
* @var int|double|null The problematic length.
50+
* The problematic length.
51+
*
52+
* @var int|double|null
5153
*/
5254
private $_length;
5355

src/PEAR2/Net/RouterOS/Message.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,19 @@ abstract class Message implements IteratorAggregate, Countable
4848
{
4949

5050
/**
51-
* @var array<string,string|resource> An array with message attributes.
52-
* Each array key is the the name of an attribute,
53-
* and the corresponding array value is the value for that attribute.
51+
* An array with message attributes.
52+
*
53+
* Each array key is the the name of an attribute,
54+
* and the corresponding array value is the value for that attribute.
55+
*
56+
* @var array<string,string|resource>
5457
*/
5558
protected $attributes = array();
5659

5760
/**
58-
* @var string An optional tag to associate the message with.
61+
* An optional tag to associate the message with.
62+
*
63+
* @var string
5964
*/
6065
private $_tag = null;
6166

src/PEAR2/Net/RouterOS/NotSupportedException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class NotSupportedException extends E implements Exception
4545
const CODE_ARG_PROHIBITED = 60001;
4646

4747
/**
48-
* @var mixed The unsupported value.
48+
* The unsupported value.
49+
*
50+
* @var mixed
4951
*/
5052
private $_value;
5153

src/PEAR2/Net/RouterOS/Query.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ class Query
6363
const OP_GT = '>';
6464

6565
/**
66-
* @var array<string,string|null>[] An array of the words forming the query.
67-
* Each value is an array with the first member being the predicate
68-
* (operator and name), and the second member being the value
69-
* for the predicate.
66+
* An array of the words forming the query.
67+
*
68+
* Each value is an array with the first member being the predicate
69+
* (operator and name), and the second member being the value
70+
* for the predicate.
71+
*
72+
* @var array<string,string|null>[]
7073
*/
7174
protected $words = array();
7275

@@ -242,14 +245,14 @@ private function _send(Communicator $com)
242245

243246
/**
244247
* Verifies the query.
245-
*
248+
*
246249
* Verifies the query against a communicator, i.e. whether the query
247250
* could successfully be sent (assuming the connection is still opened).
248-
*
251+
*
249252
* @param Communicator $com The Communicator to check against.
250-
*
253+
*
251254
* @return $this The query object itself.
252-
*
255+
*
253256
* @throws LengthException If the resulting length of an API word is not
254257
* supported.
255258
*/

src/PEAR2/Net/RouterOS/Registry.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,30 @@
4242
class Registry
4343
{
4444
/**
45-
* @var SHM The storage.
45+
* The storage.
46+
*
47+
* @var SHM
4648
*/
4749
protected $shm;
4850

4951
/**
50-
* @var int ID of request. Populated at first instance in request.
52+
* ID of request. Populated at first instance in request.
53+
*
54+
* @var int
5155
*/
5256
protected static $requestId = -1;
5357

5458
/**
55-
* @var int ID to be given to next instance, after incrementing it.
59+
* ID to be given to next instance, after incrementing it.
60+
*
61+
* @var int
5662
*/
5763
protected static $instanceIdSeed = -1;
5864

5965
/**
60-
* @var int ID of instance within the request.
66+
* ID of instance within the request.
67+
*
68+
* @var int
6169
*/
6270
protected $instanceId;
6371

src/PEAR2/Net/RouterOS/Request.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ class Request extends Message
3838
{
3939

4040
/**
41-
* @var string The command to be executed.
41+
* The command to be executed.
42+
*
43+
* @var string
4244
*/
4345
private $_command;
4446

4547
/**
46-
* @var Query A query for the command.
48+
* A query for the command.
49+
*
50+
* @var Query
4751
*/
4852
private $_query;
4953

@@ -341,14 +345,14 @@ private function _send(Communicator $com)
341345

342346
/**
343347
* Verifies the request.
344-
*
348+
*
345349
* Verifies the request against a communicator, i.e. whether the request
346350
* could successfully be sent (assuming the connection is still opened).
347-
*
351+
*
348352
* @param Communicator $com The Communicator to check against.
349-
*
353+
*
350354
* @return $this The request object itself.
351-
*
355+
*
352356
* @throws LengthException If the resulting length of an API word is not
353357
* supported.
354358
*/

0 commit comments

Comments
 (0)