Issues (12)

cisco_parser.php (2 issues)

Labels
1
<?php
2
/* This was probably written before i wrote the class, so need to update a few links to use the class instead */
3
include 'class.cisco.php';
4
if (!isset($_SERVER['argv'][1]) || !file_exists($_SERVER['argv'][1])) {
5
	die('Specify a (valid) file as the first argument to get it parsed');
6
}
7
$file = str_replace("\r", '', file_get_contents($_SERVER['argv'][1]));
8
$lines = explode("\n", $file);
9
$start_str = 'Building configuration...';
10
$x = 0;
11
while (mb_substr($lines[$x], 0, mb_strlen($start_str)) != $start_str) {
12
	$x++;
13
}
14
$info = [];
15
if (preg_match('/^Current configuration\s*:\s*(?P<config_bytes>$|\d+)( bytes)$/', $lines[$x + 2], $matches)) {
16
	$info['config_bytes'] = $matches['config_bytes'];
17
}
18
$x += 3;
19
$cisco = new cisco();
0 ignored issues
show
The call to cisco::__construct() has too few arguments starting with hostname. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
$cisco = /** @scrutinizer ignore-call */ new cisco();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
20
$info['data'] = $cisco->parse_cisco_children($lines, $x + 1);
0 ignored issues
show
The method parse_cisco_children() does not exist on cisco. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
$info['data'] = $cisco->/** @scrutinizer ignore-call */ parse_cisco_children($lines, $x + 1);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21
print_r($info);
22