Merge pull request #5961 from colemanw/CRM-16577
[civicrm-core.git] / bin / cli.class.php
index d1db53c541d28b48bddc9c2690c3de4ba558a623..be58c1c654c72e3a5427748ef4c4505612c9578a 100644 (file)
@@ -8,7 +8,7 @@
  |                                                                    |
  | CiviCRM is free software; you can copy, modify, and distribute it  |
  | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007.                                       |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
  |                                                                    |
  | CiviCRM is distributed in the hope that it will be useful, but     |
  | WITHOUT ANY WARRANTY; without even the implied warranty of         |
  | See the GNU Affero General Public License for more details.        |
  |                                                                    |
  | You should have received a copy of the GNU Affero General Public   |
- | License along with this program; if not, contact CiviCRM LLC       |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
  | at info[AT]civicrm[DOT]org. If you have questions about the        |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  * This files provides several classes for doing command line work with
@@ -77,6 +78,11 @@ class civicrm_cli {
     return TRUE;
   }
 
+  /**
+   * Ensure function is being run from the cli.
+   *
+   * @return bool
+   */
   public function _accessing_from_cli() {
     if (PHP_SAPI === 'cli') {
       return TRUE;
@@ -174,7 +180,7 @@ class civicrm_cli {
         $this->_joblog = TRUE;
       }
       else {
-        while (list($short, $long) = each($this->_additional_arguments)) {
+        foreach ($this->_additional_arguments as $short => $long) {
           if ($arg == '-' . $short || $arg == '--' . $long) {
             $property = '_' . $long;
             $this->$property = $value;
@@ -307,6 +313,7 @@ class civicrm_cli {
     // that properly logs
     print "$error\n";
   }
+
 }
 
 /**
@@ -348,6 +355,7 @@ class civicrm_cli_csv_exporter extends civicrm_cli {
     fclose($out);
     echo "\n";
   }
+
 }
 
 /**
@@ -368,6 +376,9 @@ class civicrm_cli_csv_file extends civicrm_cli {
     parent::initialize();
   }
 
+  /**
+   * Run CLI function.
+   */
   public function run() {
     $this->row = 1;
     $handle = fopen($this->_file, "r");
@@ -400,7 +411,6 @@ class civicrm_cli_csv_file extends civicrm_cli {
       $this->processLine($params);
     }
     fclose($handle);
-    return NULL;
   }
 
   /* return a params as expected */
@@ -422,6 +432,7 @@ class civicrm_cli_csv_file extends civicrm_cli {
     $params['version'] = 3;
     return $params;
   }
+
 }
 
 /**
@@ -442,6 +453,7 @@ class civicrm_cli_csv_importer extends civicrm_cli_csv_file {
       echo "\nline " . $this->row . ": created " . $this->_entity . " id: " . $result['id'] . "\n";
     }
   }
+
 }
 
 /**
@@ -462,4 +474,5 @@ class civicrm_cli_csv_deleter extends civicrm_cli_csv_file {
       echo "\nline " . $this->row . ": deleted\n";
     }
   }
+
 }