Skip to content

Commit 277e070

Browse files
committed
Various breaking changes and fixes (see diff of RELEASE-1.0.0b5 for details);
Stub and console fixes; CS and MD fixes; Dep bump in packaging files.
1 parent de8cd0b commit 277e070

24 files changed

+805
-455
lines changed

RELEASE-1.0.0b5

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
Console and some overall improvements.
1+
Console, some overall improvements, including BREAKING CHANGES.
22

33
* The PHAR file is now also a console. When installed, the console is available from the executable "roscon".
44
* __BREAKING CHANGES:__
5-
- Removed Message::getAllArguments() in favor of IteratorAggregate implementation that returns an ArrayObject. For most intents and purposes, you should be able to just search&replace "->getAllArguments()" with an empty string (that will implicitly call getIterator()). If you require the arguments as a "real" array, you can replace "->getAllArguments()" with "->getIterator()->getArrayCopy()".
5+
- Response::getArgument() is renamed to Response::getProperty() (Note: Request::getArgument() is still valid). Response::getArgument() is left issuing an E_USER_DEPRECATED notice, and will be removed in a later release.
6+
- Message::getAllArguments() is removed in favor of IteratorAggregate implementation that returns an ArrayObject. For most intents and purposes, you should be able to just search&replace "->getAllArguments()" with an empty string (that will implicitly call getIterator()). If you require the arguments as a "real" array, you can replace "->getAllArguments()" with "->getIterator()->getArrayCopy()".
67
- Message::\_\_invoke() without arguments is now a shortcut for getTag() instead of getting all arguments.
78
- Util::changeMenu() is now renamed to Util::setMenu() and always returns the Util object itself.
9+
- ResponseCollection::\_\_invoke() without arguments (or NULL) is now a shortcut for getting the iterator of the current response, instead of for seeking to the last response. Replace "()" with "(-1)" or "->end()" to achieve the old effect.
10+
- ResponseCollection::getLast() is removed. To get the last response, you can instead use array access (or offsetGet()) with "-1" as the offset. Or simply search&replace "->getLast()" with "->offsetGet(-1)".
11+
- ResponseCollection::getArgumentMap() is renamed to ResponseCollection::getPropertyMap().
12+
- All Query::ACTION\_\* constants are renamed to Query::OP\_\*, and shortened (GREATHER_THAN is now GT, etc.).
813
* New Util methods:
914
- getMenu() (serves the same purpose as previously Util::changeMenu() with an emptry string)
1015
- getAll()
11-
- count() (implementation of Countable, reports the number of items at the current menu)
16+
- count() (makes Util an implementation of Countable, reports the number of items at the current menu)
1217
- prepareScript()
18+
- appendScript()
1319
* Message now implements Countable, reporting the number of arguments (on COUNTER_NORMAL) or words (on COUNT_RECURSIVE).
1420
* Util::get() now uses RouterOS' "get" command, unless it returns an empty !done response (as it does for RouterOS versions prior to 6.0), in which case it automatically fallbacks to a print with a query.
1521
* Util::escapeValue() and Util::parseValue() now support associative arrays (introduced in RouterOS 6.2).
1622
* Util::escapeValue() now correctly converts DateTime objects to DateInterval objects relative to UNIX epoch time in UTC. Previously, the current time zone was used instead of UTC.
1723
* Util::add() and Util::set()/Util::edit() now support flags as values with a numeric key.
24+
* Util::filePutContents() now behaves correctly when the underlying Client has enabled streaming of responses and/or when the contents is in a stream.
25+
* Responses in ResponseCollection can now be getted or seeked to a value relative from the end by supplying a negative offset.
1826
* ResponseCollection can now be searched by argument values, if you first designate an argument name with the new ResponseCollection::setIndex() method.
1927
* ResponseCollection can now produce a sorted response collection based on user defined criteria using the new ResponseCollection::orderBy() method.
2028
* Util::find() now always returns a comma separated list when used without arguments (as opposed to ";" separated, in more recent RouterOS versions).
2129
* Response receiving now resets if an empty sentence is received, instead of throwing an exception.
30+
* New Communicator::seekableStreamLength() method, used internally by Util::filePutContents().
2231
* Doc fixes (Notably: Clarified the acceptability of seekable streams as argument values, which has been present for a long time, but never documented).
2332
* CS fixes.

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
},
1818
"require": {
1919
"php": ">=5.3.0",
20-
"pear2/net_transmitter": ">=1.0.0a4"
20+
"pear2/net_transmitter": ">=1.0.0a5"
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "@stable",
24-
"squizlabs/php_codesniffer": "@stable"
24+
"squizlabs/php_codesniffer": "@stable",
25+
"pear2/cache_shm": "dev-develop",
26+
"pear2/console_commandline": "dev-master",
27+
"pear2/console_color": "dev-develop"
2528
},
2629
"suggest": {
2730
"pear2/cache_shm": "Enables persistent connections.",

examples/sync-request-simple.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
foreach ($responses as $response) {
1111
if ($response->getType() === Response::TYPE_DATA) {
12-
echo 'IP: ', $response->getArgument('address'),
13-
' MAC: ', $response->getArgument('mac-address'),
12+
echo 'IP: ', $response->getProperty('address'),
13+
' MAC: ', $response->getProperty('mac-address'),
1414
"\n";
1515
}
1616
}

extrasetup.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616

1717
$extrafiles = array();
1818
$phpDir = Pyrus\Config::current()->php_dir;
19-
$packages = array('PEAR2/Autoload', 'PEAR2/Cache/SHM', 'PEAR2/Net/Transmitter');
19+
$packages = array(
20+
'PEAR2/Autoload',
21+
'PEAR2/Cache/SHM',
22+
'PEAR2/Console/CommandLine',
23+
'PEAR2/Console/Color',
24+
'PEAR2/Net/Transmitter'
25+
);
26+
27+
//Quick&dirty workaround for Console_CommandLine's xmlschema.rng file.
28+
$extrafiles['data/pear2.php.net/PEAR2_Console_CommandLine/xmlschema.rng']
29+
= Pyrus\Config::current()->data_dir . DIRECTORY_SEPARATOR .
30+
'pear2.php.net/PEAR2_Console_CommandLine/xmlschema.rng';
2031

2132
$oldCwd = getcwd();
2233
chdir($phpDir);

package.xml

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
<package version="2.1" xmlns="http://pear.php.net/dtd/package-2.1" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.1 http://pear.php.net/dtd/package-2.1.xsd">
33
<name>PEAR2_Net_RouterOS</name>
44
<channel>pear2.php.net</channel>
5-
<summary>RouterOS API client implementation.
6-
</summary>
5+
<summary>RouterOS API client implementation.</summary>
76
<description>RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.</description>
87
<lead>
98
<name>Vasil Rangelov</name>
109
<user>boen_robot</user>
1110
<email>boen.robot@gmail.com</email>
1211
<active>yes</active>
1312
</lead>
14-
<date>2013-10-26</date>
15-
<time>19:56:36</time>
13+
<date>2014-11-02</date>
14+
<time>07:37:22</time>
1615
<version>
1716
<release>1.0.0b5</release>
1817
<api>1.0.0</api>
@@ -22,18 +21,36 @@
2221
<api>stable</api>
2322
</stability>
2423
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL License 2.1</license>
25-
<notes>Console and some overall improvements.
24+
<notes>Console, some overall improvements, including BREAKING CHANGES.
2625

2726
* The PHAR file is now also a console. When installed, the console is available from the executable &quot;roscon&quot;.
27+
* __BREAKING CHANGES:__
28+
- Response::getArgument() is renamed to Response::getProperty() (Note: Request::getArgument() is still valid). Response::getArgument() is left issuing an E_USER_DEPRECATED notice, and will be removed in a later release.
29+
- Message::getAllArguments() is removed in favor of IteratorAggregate implementation that returns an ArrayObject. For most intents and purposes, you should be able to just search&amp;replace &quot;-&gt;getAllArguments()&quot; with an empty string (that will implicitly call getIterator()). If you require the arguments as a &quot;real&quot; array, you can replace &quot;-&gt;getAllArguments()&quot; with &quot;-&gt;getIterator()-&gt;getArrayCopy()&quot;.
30+
- Message::\_\_invoke() without arguments is now a shortcut for getTag() instead of getting all arguments.
31+
- Util::changeMenu() is now renamed to Util::setMenu() and always returns the Util object itself.
32+
- ResponseCollection::\_\_invoke() without arguments (or NULL) is now a shortcut for getting the iterator of the current response, instead of for seeking to the last response. Replace &quot;()&quot; with &quot;(-1)&quot; or &quot;-&gt;end()&quot; to achieve the old effect.
33+
- ResponseCollection::getLast() is removed. To get the last response, you can instead use array access (or offsetGet()) with &quot;-1&quot; as the offset. Or simply search&amp;replace &quot;-&gt;getLast()&quot; with &quot;-&gt;offsetGet(-1)&quot;.
34+
- ResponseCollection::getArgumentMap() is renamed to ResponseCollection::getPropertyMap().
35+
- All Query::ACTION\_\* constants are renamed to Query::OP\_\*, and shortened (GREATHER_THAN is now GT, etc.).
2836
* New Util methods:
29-
- getall()
30-
- count()
37+
- getMenu() (serves the same purpose as previously Util::changeMenu() with an emptry string)
38+
- getAll()
39+
- count() (makes Util an implementation of Countable, reports the number of items at the current menu)
3140
- prepareScript()
41+
- appendScript()
42+
* Message now implements Countable, reporting the number of arguments (on COUNTER_NORMAL) or words (on COUNT_RECURSIVE).
3243
* Util::get() now uses RouterOS' &quot;get&quot; command, unless it returns an empty !done response (as it does for RouterOS versions prior to 6.0), in which case it automatically fallbacks to a print with a query.
3344
* Util::escapeValue() and Util::parseValue() now support associative arrays (introduced in RouterOS 6.2).
45+
* Util::escapeValue() now correctly converts DateTime objects to DateInterval objects relative to UNIX epoch time in UTC. Previously, the current time zone was used instead of UTC.
3446
* Util::add() and Util::set()/Util::edit() now support flags as values with a numeric key.
35-
* Util::changeMenu() now returns the Util object itself, except when you supply an empty string, when the current menu is returned (as before).
47+
* Util::filePutContents() now behaves correctly when the underlying Client has enabled streaming of responses and/or when the contents is in a stream.
48+
* Responses in ResponseCollection can now be getted or seeked to a value relative from the end by supplying a negative offset.
3649
* ResponseCollection can now be searched by argument values, if you first designate an argument name with the new ResponseCollection::setIndex() method.
50+
* ResponseCollection can now produce a sorted response collection based on user defined criteria using the new ResponseCollection::orderBy() method.
51+
* Util::find() now always returns a comma separated list when used without arguments (as opposed to &quot;;&quot; separated, in more recent RouterOS versions).
52+
* Response receiving now resets if an empty sentence is received, instead of throwing an exception.
53+
* New Communicator::seekableStreamLength() method, used internally by Util::filePutContents().
3754
* Doc fixes (Notably: Clarified the acceptability of seekable streams as argument values, which has been present for a long time, but never documented).
3855
* CS fixes.</notes>
3956
<contents>
@@ -64,13 +81,19 @@
6481
<file role="doc" name="sync-request-simple.php"/>
6582
</dir>
6683
<dir name="scripts" baseinstalldir="/">
84+
<file role="script" name="roscon">
85+
<tasks:replace type="package-info" to="version" from="GIT: $Id$"/>
86+
<tasks:replace type="package-info" to="summary" from="~~summary~~"/>
87+
<tasks:replace type="package-info" to="description" from="~~description~~"/>
88+
</file>
6789
<file role="script" name="roscon.bat">
6890
<tasks:windowseol/>
6991
</file>
7092
<file role="script" name="roscon.php">
7193
<tasks:replace type="pear-config" to="php_dir" from="../src"/>
7294
<tasks:replace type="pear-config" to="php_dir" from="../../Net_Transmitter.git/src"/>
7395
<tasks:replace type="pear-config" to="php_dir" from="../../Console_Color.git/src"/>
96+
<tasks:replace type="pear-config" to="php_dir" from="../../Console_CommandLine.git/src"/>
7497
<tasks:replace type="pear-config" to="data_dir" from="@PEAR2_DATA_DIR@"/>
7598
<tasks:replace type="package-info" to="channel" from="@PACKAGE_CHANNEL@"/>
7699
<tasks:replace type="package-info" to="name" from="@PACKAGE_NAME@"/>
@@ -196,6 +219,11 @@
196219
<file role="test" name="Safe.php"/>
197220
<file role="test" name="Unsafe.php"/>
198221
</dir>
222+
<dir name="Extra">
223+
<file role="test" name="isHostnameInvalid.php">
224+
<tasks:replace type="package-info" to="version" from="GIT: $Id$"/>
225+
</file>
226+
</dir>
199227
<dir name="Util">
200228
<dir name="Safe">
201229
<dir name="NonPersistent">
@@ -235,6 +263,7 @@
235263
<file role="test" name="phpunit.xml">
236264
<tasks:replace type="pear-config" to="php_dir" from="../src"/>
237265
</file>
266+
<file role="test" name="RouterOS_SETTINGS.rsc"/>
238267
</dir>
239268
</dir>
240269
</contents>
@@ -249,10 +278,10 @@
249278
<package>
250279
<name>PEAR2_Net_Transmitter</name>
251280
<channel>pear2.php.net</channel>
252-
<min>1.0.0a4</min>
281+
<min>1.0.0a5</min>
253282
</package>
254283
<extension>
255-
<name>PCRE</name>
284+
<name>pcre</name>
256285
</extension>
257286
</required>
258287
<optional>
@@ -264,7 +293,17 @@
264293
<package>
265294
<name>PEAR2_Cache_SHM</name>
266295
<channel>pear2.php.net</channel>
267-
<min>0.1.2</min>
296+
<min>0.1.3</min>
297+
</package>
298+
<package>
299+
<name>PEAR2_Console_CommandLine</name>
300+
<channel>pear2.php.net</channel>
301+
<min>0.2.1</min>
302+
</package>
303+
<package>
304+
<name>PEAR2_Console_Color</name>
305+
<channel>pear2.php.net</channel>
306+
<min>1.0.0</min>
268307
</package>
269308
<extension>
270309
<name>iconv</name>
@@ -283,8 +322,9 @@
283322
<install name="examples/send-and-forget.php" as="examples/send-and-forget.php"/>
284323
<install name="examples/sync-request-arguments.php" as="examples/sync-request-arguments.php"/>
285324
<install name="examples/sync-request-simple.php" as="examples/sync-request-simple.php"/>
325+
<install name="scripts/roscon" as="roscon"/>
286326
<install name="scripts/roscon.bat" as="roscon.bat"/>
287-
<install name="scripts/roscon.php" as="roscon"/>
327+
<install name="scripts/roscon.php" as="roscon.php"/>
288328
<install name="src/PEAR2/Net/RouterOS/Client.php" as="PEAR2/Net/RouterOS/Client.php"/>
289329
<install name="src/PEAR2/Net/RouterOS/Communicator.php" as="PEAR2/Net/RouterOS/Communicator.php"/>
290330
<install name="src/PEAR2/Net/RouterOS/DataFlowException.php" as="PEAR2/Net/RouterOS/DataFlowException.php"/>
@@ -317,8 +357,10 @@
317357
<install name="tests/Client/Unsafe/Persistent/EncryptedTest.php" as="Client/Unsafe/Persistent/EncryptedTest.php"/>
318358
<install name="tests/Client/Unsafe/Persistent/UnencryptedTest.php" as="Client/Unsafe/Persistent/UnencryptedTest.php"/>
319359
<install name="tests/ConnectionTest.php" as="ConnectionTest.php"/>
360+
<install name="tests/Extra/isHostnameInvalid.php" as="Extra/isHostnameInvalid.php"/>
320361
<install name="tests/HandlingTest.php" as="HandlingTest.php"/>
321362
<install name="tests/phpunit.xml" as="phpunit.xml"/>
363+
<install name="tests/RouterOS_SETTINGS.rsc" as="RouterOS_SETTINGS.rsc"/>
322364
<install name="tests/Util/Safe.php" as="Util/Safe.php"/>
323365
<install name="tests/Util/Safe/NonPersistent/EncryptedTest.php" as="Util/Safe/NonPersistent/EncryptedTest.php"/>
324366
<install name="tests/Util/Safe/NonPersistent/UnencryptedTest.php" as="Util/Safe/NonPersistent/UnencryptedTest.php"/>

packagexmlsetup.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
'type' => 'pear-config',
5656
'to' => 'php_dir'
5757
),
58+
'../../Console_CommandLine.git/src' => array(
59+
'type' => 'pear-config',
60+
'to' => 'php_dir'
61+
),
5862
'@PEAR2_DATA_DIR@' => array(
5963
'type' => 'pear-config',
6064
'to' => 'data_dir'

scripts/roscon

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/**
5+
* ~~summary~~
6+
*
7+
* ~~description~~
8+
*
9+
* PHP version 5.3
10+
*
11+
* @category Net
12+
* @package PEAR2_Net_RouterOS
13+
* @author Vasil Rangelov <boen.robot@gmail.com>
14+
* @copyright 2011 Vasil Rangelov
15+
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
16+
* @version GIT: $Id$
17+
* @link http://pear2.php.net/PEAR2_Net_RouterOS
18+
*/
19+
20+
/**
21+
* Run the console.
22+
*/
23+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'roscon.php';

0 commit comments

Comments
 (0)