cimmwolf /
sitemap-parser
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | if (php_sapi_name() != 'cli') { |
||
| 4 | die('Must run from command line'); |
||
| 5 | } |
||
| 6 | |||
| 7 | error_reporting(E_ALL | E_STRICT); |
||
| 8 | ini_set('display_errors', 1); |
||
| 9 | ini_set('log_errors', 0); |
||
| 10 | ini_set('html_errors', 0); |
||
| 11 | |||
| 12 | require_once __DIR__ . '/vendor/autoload.php'; |
||
| 13 | |||
| 14 | |||
| 15 | $commands = ['checkurls', 'metadata']; |
||
| 16 | |||
| 17 | if (!in_array($argv[1], $commands)) { |
||
| 18 | echo 'Wrong command.' . PHP_EOL; |
||
| 19 | exit; |
||
| 20 | } |
||
| 21 | |||
| 22 | $strict = in_array('--strict', $_SERVER['argv']); |
||
| 23 | $arguments = new \cli\Arguments(compact('strict')); |
||
| 24 | $arguments->addFlag(['help', 'h'], 'Show this help screen'); |
||
|
0 ignored issues
–
show
|
|||
| 25 | |||
| 26 | $arguments->addOption(['site', 's'], [ |
||
| 27 | 'description' => 'Site URL']); |
||
| 28 | |||
| 29 | $arguments->parse(); |
||
| 30 | |||
| 31 | if ($arguments['help']) { |
||
| 32 | echo $arguments->getHelpScreen(); |
||
| 33 | echo "\n\n"; |
||
| 34 | exit; |
||
| 35 | } |
||
| 36 | |||
| 37 | \cli\line(" Getting sitemap of %s...", $arguments['site']); |
||
| 38 | |||
| 39 | $sitemap = simplexml_load_file($arguments['site'] . '/sitemap.xml'); |
||
| 40 | |||
| 41 | if ($sitemap === false) { |
||
| 42 | \cli\err('Error'); |
||
| 43 | exit; |
||
| 44 | } |
||
| 45 | |||
| 46 | require_once __DIR__ . '/commands/' . $argv[1] . '.php'; |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: