Skip to content

Commit 03b0be8

Browse files
committed
Implemented some of the easier scrutinizer-ci fixes, located at packagexmlsetup.php, roscon.php UnexpectedValueException.php;
Updated examples; Added a .gitignore to ignore "vendor"; Added dev dependencies in composer.json;
1 parent c4b7989 commit 03b0be8

13 files changed

+217
-186
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

composer.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,23 @@
1919
"php": ">=5.3.0",
2020
"pear2/net_transmitter": ">=1.0.0a4"
2121
},
22+
"require-dev": {
23+
"phpunit/phpunit": "@stable",
24+
"squizlabs/php_codesniffer": "@stable",
25+
"scrutinizer/php-analyzer": "dev-master"
26+
},
2227
"suggest": {
23-
"pear2/cache_shm": ">=0.1.2",
24-
"ext-apc": ">=3.0.13",
25-
"ext-wincache": ">=1.1.0",
26-
"ext-openssl": "*"
28+
"pear2/cache_shm": "Enables persistent connections.",
29+
"ext-apc": "This or Wincache is required for persistent connections.",
30+
"ext-wincache": "This or APC is required for persistent connections. Reccomended instead of APC on Windows.",
31+
"ext-openssl": "Enables encrypted connections."
2732
},
2833
"autoload": {
2934
"psr-0": {
3035
"PEAR2\\Net\\RouterOS\\": "src/",
3136
"PEAR2\\Net\\Transmitter\\": "vendor/pear2/net_transmitter/src/",
32-
"PEAR2\\Cache\\SHM": "vendor/pear2/cache_shm/src/"
37+
"PEAR2\\Cache\\SHM": "vendor/pear2/cache_shm/src/",
38+
"PEAR2\\Console\\Color": "vendor/pear2/console_color/src/"
3339
}
3440
},
3541
"bin": ["scripts/roscon.php"],

data/roscon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Defaults to PHP's default_socket_timeout ini option.</description>
5151
</option>
5252
<option name="isColored">
5353
<long_name>--colors</long_name>
54-
<description>Choose whether to color output. Possible values:
54+
<description>Choose whether to color output (requires PEAR2_Console_Color). Possible values:
5555
"auto" - color is always enabled, except on Windows, where ANSICON must be installed (detected via the ANSICON_VER environment variable).
5656
"yes" - force colored output.
5757
"no" - force no coloring of output.

examples/callback-and-loop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
2-
namespace PEAR2\Net\RouterOS;
2+
use PEAR2\Net\RouterOS;
33

4-
require_once 'PEAR2/Net/RouterOS/Autoload.php';
4+
require_once 'PEAR2/Autoload.php';
55

6-
$client = new Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.0.1', 'admin');
77

88
//Custom function, defined specifically for the example
99
$responseHandler = function ($response) {
@@ -12,7 +12,7 @@
1212
}
1313
};
1414

15-
$addRequest = new Request('/ip/arp/add');
15+
$addRequest = new RouterOS\Request('/ip/arp/add');
1616

1717
$addRequest->setArgument('address', '192.168.0.100');
1818
$addRequest->setArgument('mac-address', '00:00:00:00:00:01');

examples/loop-and-extract.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
namespace PEAR2\Net\RouterOS;
2+
use PEAR2\Net\RouterOS;
33

4-
require_once 'PEAR2/Net/RouterOS/Autoload.php';
4+
require_once 'PEAR2/Autoload.php';
55

6-
$client = new Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.0.1', 'admin');
77

8-
$addRequest = new Request('/ip/arp/add');
8+
$addRequest = new RouterOS\Request('/ip/arp/add');
99

1010
$addRequest->setArgument('address', '192.168.0.100');
1111
$addRequest->setArgument('mac-address', '00:00:00:00:00:01');
@@ -21,7 +21,7 @@
2121

2222
$responses = $client->extractNewResponses();
2323
foreach ($responses as $response) {
24-
if ($responses->getType() !== Response::TYPE_FINAL) {
24+
if ($response->getType() !== Response::TYPE_FINAL) {
2525
echo "Error with {$response->getTag()}!\n";
2626
} else {
2727
echo "OK with {$response->getTag()}!\n";

examples/send-and-complete.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
namespace PEAR2\Net\RouterOS;
2+
use PEAR2\Net\RouterOS;
33

4-
require_once 'PEAR2/Net/RouterOS/Autoload.php';
4+
require_once 'PEAR2/Autoload.php';
55

6-
$client = new Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.0.1', 'admin');
77

8-
$addRequest = new Request('/ip/arp/add');
8+
$addRequest = new RouterOS\Request('/ip/arp/add');
99

1010
$addRequest->setArgument('address', '192.168.0.100');
1111
$addRequest->setArgument('mac-address', '00:00:00:00:00:01');

examples/send-and-forget.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
namespace PEAR2\Net\RouterOS;
2+
use PEAR2\Net\RouterOS;
33

4-
require_once 'PEAR2/Net/RouterOS/Autoload.php';
4+
require_once 'PEAR2/Autoload.php';
55

6-
$client = new Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.0.1', 'admin');
77

8-
$addRequest = new Request('/ip/arp/add');
8+
$addRequest = new RouterOS\Request('/ip/arp/add');
99

1010
$addRequest->setArgument('address', '192.168.0.100');
1111
$addRequest->setArgument('mac-address', '00:00:00:00:00:01');

examples/sync-request-arguments.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
namespace PEAR2\Net\RouterOS;
2+
use PEAR2\Net\RouterOS;
33

4-
require_once 'PEAR2/Net/RouterOS/Autoload.php';
4+
require_once 'PEAR2/Autoload.php';
55

6-
$client = new Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.0.1', 'admin');
77

8-
$addRequest = new Request('/ip/arp/add');
8+
$addRequest = new RouterOS\Request('/ip/arp/add');
99

1010
$addRequest->setArgument('address', '192.168.0.100');
1111
$addRequest->setArgument('mac-address', '00:00:00:00:00:01');

examples/sync-request-simple.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
namespace PEAR2\Net\RouterOS;
2+
use PEAR2\Net\RouterOS;
33

4-
require_once 'PEAR2/Net/RouterOS/Autoload.php';
4+
require_once 'PEAR2/Autoload.php';
55

6-
$client = new Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.0.1', 'admin');
77

8-
$responses = $client->sendSync(new Request('/ip/arp/print'));
8+
$responses = $client->sendSync(new RouterOS\Request('/ip/arp/print'));
99

1010
foreach ($responses as $response) {
1111
if ($response->getType() === Response::TYPE_DATA) {

packagexmlsetup.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,19 @@
8585
)
8686
);
8787

88+
if (!isset($package)) {
89+
die('This file must be executed via "pyrus.phar make".');
90+
}
91+
8892
$packageGen = function (
8993
array $config,
9094
v2 $package,
9195
v2 $compatible = null
9296
) {
93-
$hasCompatible = null !== $compatible;
9497

9598
$tasksNs = $package->getTasksNs();
96-
if ($hasCompatible) {
97-
$cTaskNs = $compatible->getTasksNs();
99+
if ($compatible) {
100+
$cTasksNs = $compatible->getTasksNs();
98101
}
99102

100103
$oldCwd = getcwd();
@@ -108,14 +111,7 @@
108111
RecursiveIteratorIterator::LEAVES_ONLY
109112
) as $path) {
110113
$filename = substr($path->getPathname(), 2);
111-
112-
if ($hasCompatible) {
113-
$cFilename = str_replace(
114-
'src/',
115-
'php/',
116-
$filename
117-
);
118-
}
114+
$cFilename = str_replace('src/', 'php/', $filename);
119115

120116
if (isset($package->files[$filename])) {
121117
$parsedFilename = pathinfo($filename);
@@ -154,7 +150,7 @@
154150
)
155151
);
156152

157-
if ($hasCompatible) {
153+
if ($compatible) {
158154
$compatible->files[$cFilename] = array_merge_recursive(
159155
$compatible->files[$cFilename]->getArrayCopy(),
160156
array(
@@ -178,7 +174,7 @@
178174
)
179175
);
180176

181-
if ($hasCompatible) {
177+
if ($compatible) {
182178
$compatible->files[$cFilename] = array_merge_recursive(
183179
$compatible->files[$cFilename]->getArrayCopy(),
184180
array(

0 commit comments

Comments
 (0)