INFRA-132 - @param type fixes
[civicrm-core.git] / CRM / Import / Parser.php
index c3a0e8ea3b69c8be82a86be3fe438694fff477fe..749ec38478bec16043df0d516356a0588a710059 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -38,105 +38,105 @@ abstract class CRM_Import_Parser {
   /**
    * Settings
    */
-  CONST MAX_ERRORS = 250, MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30;
+  const MAX_ERRORS = 250, MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30;
 
   /**
    * Return codes
    */
-  CONST VALID = 1, WARNING = 2, ERROR = 4, CONFLICT = 8, STOP = 16, DUPLICATE = 32, MULTIPLE_DUPE = 64, NO_MATCH = 128, UNPARSED_ADDRESS_WARNING = 256;
+  const VALID = 1, WARNING = 2, ERROR = 4, CONFLICT = 8, STOP = 16, DUPLICATE = 32, MULTIPLE_DUPE = 64, NO_MATCH = 128, UNPARSED_ADDRESS_WARNING = 256;
 
   /**
    * Parser modes
    */
-  CONST MODE_MAPFIELD = 1, MODE_PREVIEW = 2, MODE_SUMMARY = 4, MODE_IMPORT = 8;
+  const MODE_MAPFIELD = 1, MODE_PREVIEW = 2, MODE_SUMMARY = 4, MODE_IMPORT = 8;
 
   /**
    * Codes for duplicate record handling
    */
-  CONST DUPLICATE_SKIP = 1, DUPLICATE_REPLACE = 2, DUPLICATE_UPDATE = 4, DUPLICATE_FILL = 8, DUPLICATE_NOCHECK = 16;
+  const DUPLICATE_SKIP = 1, DUPLICATE_REPLACE = 2, DUPLICATE_UPDATE = 4, DUPLICATE_FILL = 8, DUPLICATE_NOCHECK = 16;
 
   /**
    * Contact types
    */
-  CONST CONTACT_INDIVIDUAL = 1, CONTACT_HOUSEHOLD = 2, CONTACT_ORGANIZATION = 4;
+  const CONTACT_INDIVIDUAL = 1, CONTACT_HOUSEHOLD = 2, CONTACT_ORGANIZATION = 4;
 
 
   /**
-   * total number of non empty lines
+   * Total number of non empty lines
    */
   protected $_totalCount;
 
   /**
-   * running total number of valid lines
+   * Running total number of valid lines
    */
   protected $_validCount;
 
   /**
-   * running total number of invalid rows
+   * Running total number of invalid rows
    */
   protected $_invalidRowCount;
 
   /**
-   * maximum number of non-empty/comment lines to process
+   * Maximum number of non-empty/comment lines to process
    *
    * @var int
    */
   protected $_maxLinesToProcess;
 
   /**
-   * maximum number of invalid rows to store
+   * Maximum number of invalid rows to store
    */
   protected $_maxErrorCount;
 
   /**
-   * array of error lines, bounded by MAX_ERROR
+   * Array of error lines, bounded by MAX_ERROR
    */
   protected $_errors;
 
   /**
-   * total number of conflict lines
+   * Total number of conflict lines
    */
   protected $_conflictCount;
 
   /**
-   * array of conflict lines
+   * Array of conflict lines
    */
   protected $_conflicts;
 
   /**
-   * total number of duplicate (from database) lines
+   * Total number of duplicate (from database) lines
    */
   protected $_duplicateCount;
 
   /**
-   * array of duplicate lines
+   * Array of duplicate lines
    */
   protected $_duplicates;
 
   /**
-   * running total number of warnings
+   * Running total number of warnings
    */
   protected $_warningCount;
 
   /**
-   * maximum number of warnings to store
+   * Maximum number of warnings to store
    */
   protected $_maxWarningCount = self::MAX_WARNINGS;
 
   /**
-   * array of warning lines, bounded by MAX_WARNING
+   * Array of warning lines, bounded by MAX_WARNING
    */
   protected $_warnings;
 
   /**
-   * array of all the fields that could potentially be part
+   * Array of all the fields that could potentially be part
    * of this import process
    * @var array
    */
   protected $_fields;
 
   /**
-   * array of the fields that are actually part of the import process
+   * Array of the fields that are actually part of the import process
    * the position in the array also dictates their position in the import
    * file
    * @var array
@@ -144,42 +144,42 @@ abstract class CRM_Import_Parser {
   protected $_activeFields;
 
   /**
-   * cache the count of active fields
+   * Cache the count of active fields
    *
    * @var int
    */
   protected $_activeFieldCount;
 
   /**
-   * cache of preview rows
+   * Cache of preview rows
    *
    * @var array
    */
   protected $_rows;
 
   /**
-   * filename of error data
+   * Filename of error data
    *
    * @var string
    */
   protected $_errorFileName;
 
   /**
-   * filename of conflict data
+   * Filename of conflict data
    *
    * @var string
    */
   protected $_conflictFileName;
 
   /**
-   * filename of duplicate data
+   * Filename of duplicate data
    *
    * @var string
    */
   protected $_duplicateFileName;
 
   /**
-   * contact type
+   * Contact type
    *
    * @var int
    */
@@ -188,7 +188,7 @@ abstract class CRM_Import_Parser {
   /**
    * Class constructor
    */
-  function __construct() {
+  public function __construct() {
     $this->_maxLinesToProcess = 0;
     $this->_maxErrorCount = self::MAX_ERRORS;
   }
@@ -197,21 +197,52 @@ abstract class CRM_Import_Parser {
    * Abstract function definitions
    */
   abstract function init();
+
+  /**
+   * @return mixed
+   */
   abstract function fini();
+
+  /**
+   * @param $values
+   *
+   * @return mixed
+   */
   abstract function mapField(&$values);
+
+  /**
+   * @param $values
+   *
+   * @return mixed
+   */
   abstract function preview(&$values);
+
+  /**
+   * @param $values
+   *
+   * @return mixed
+   */
   abstract function summary(&$values);
+
+  /**
+   * @param $onDuplicate
+   * @param $values
+   *
+   * @return mixed
+   */
   abstract function import($onDuplicate, &$values);
 
   /**
    * Set and validate field values
    *
-   * @param $elements : array
-   * @param $erroneousField : reference
+   * @param array $elements
+   *   : array.
+   * @param $erroneousField
+   *   : reference.
    *
    * @return int
    */
-  function setActiveFieldValues($elements, &$erroneousField) {
+  public function setActiveFieldValues($elements, &$erroneousField) {
     $maxCount = count($elements) < $this->_activeFieldCount ? count($elements) : $this->_activeFieldCount;
     for ($i = 0; $i < $maxCount; $i++) {
       $this->_activeFields[$i]->setValue($elements[$i]);
@@ -239,9 +270,8 @@ abstract class CRM_Import_Parser {
    * Format the field values for input to the api
    *
    * @return array (reference) associative array of name/value pairs
-   * @access public
    */
-  function &getActiveFieldParams() {
+  public function &getActiveFieldParams() {
     $params = array();
     for ($i = 0; $i < $this->_activeFieldCount; $i++) {
       if (isset($this->_activeFields[$i]->_value)
@@ -255,7 +285,10 @@ abstract class CRM_Import_Parser {
     return $params;
   }
 
-  function getSelectValues() {
+  /**
+   * @return array
+   */
+  public function getSelectValues() {
     $values = array();
     foreach ($this->_fields as $name => $field) {
       $values[$name] = $field->_title;
@@ -263,7 +296,10 @@ abstract class CRM_Import_Parser {
     return $values;
   }
 
-  function getSelectTypes() {
+  /**
+   * @return array
+   */
+  public function getSelectTypes() {
     $values = array();
     foreach ($this->_fields as $name => $field) {
       if (isset($field->_hasLocationType)) {
@@ -273,7 +309,10 @@ abstract class CRM_Import_Parser {
     return $values;
   }
 
-  function getHeaderPatterns() {
+  /**
+   * @return array
+   */
+  public function getHeaderPatterns() {
     $values = array();
     foreach ($this->_fields as $name => $field) {
       if (isset($field->_headerPattern)) {
@@ -283,7 +322,10 @@ abstract class CRM_Import_Parser {
     return $values;
   }
 
-  function getDataPatterns() {
+  /**
+   * @return array
+   */
+  public function getDataPatterns() {
     $values = array();
     foreach ($this->_fields as $name => $field) {
       $values[$name] = $field->_dataPattern;
@@ -299,9 +341,8 @@ abstract class CRM_Import_Parser {
    *
    * @return void
    * @static
-   * @access public
    */
-  static function encloseScrub(&$values, $enclosure = "'") {
+  public static function encloseScrub(&$values, $enclosure = "'") {
     if (empty($values)) {
       return;
     }
@@ -312,14 +353,13 @@ abstract class CRM_Import_Parser {
   }
 
   /**
-   * setter function
+   * Setter function
    *
    * @param int $max
    *
    * @return void
-   * @access public
    */
-  function setMaxLinesToProcess($max) {
+  public function setMaxLinesToProcess($max) {
     $this->_maxLinesToProcess = $max;
   }
 
@@ -330,7 +370,7 @@ abstract class CRM_Import_Parser {
    * @return string
    * @static
    */
-  static function errorFileName($type) {
+  public static function errorFileName($type) {
     $fileName = NULL;
     if (empty($type)) {
       return $fileName;
@@ -370,7 +410,7 @@ abstract class CRM_Import_Parser {
    * @return string
    * @static
    */
-  static function saveFileName($type) {
+  public static function saveFileName($type) {
     $fileName = NULL;
     if (empty($type)) {
       return $fileName;