tweeper: avoid a reference to $argv in non-cli mode
authorAntonio Ospite <ao2@ao2.it>
Wed, 29 Jul 2015 20:56:42 +0000 (22:56 +0200)
committerAntonio Ospite <ao2@ao2.it>
Wed, 29 Jul 2015 20:58:28 +0000 (22:58 +0200)
$argv is not defined in non-cli mode, so protect its usage behind an
is_cli() check.

For instance, this avoids a message in the PHP built-in web server, when
usage() gets called:

  PHP Notice:  Undefined variable: argv in .../tweeper.php on line 357

tweeper.php

index f07382b..a9fce9b 100644 (file)
@@ -354,7 +354,7 @@ if (is_cli()) {
 }
 
 if (!isset($options['src_url'])) {
 }
 
 if (!isset($options['src_url'])) {
-  fwrite($ERROR_STREAM, usage($argv));
+  fwrite($ERROR_STREAM, usage(is_cli() ? $argv : NULL));
   exit(1);
 }
 
   exit(1);
 }