INFRA-132 - Spaces around "."
[civicrm-core.git] / CRM / Core / CodeGen / Specification.php
index 53b47f8a0096763dd879eb1afb82aa56dd0bfe00..b15d3208d867cd83ac056ebc6d7a08281a561988 100644 (file)
@@ -13,12 +13,13 @@ class CRM_Core_CodeGen_Specification {
    * Read and parse.
    *
    * @param $schemaPath
-   * @param string $buildVersion which version of the schema to build
+   * @param string $buildVersion
+   *   Which version of the schema to build.
    */
   public function parse($schemaPath, $buildVersion) {
     $this->buildVersion = $buildVersion;
 
-    echo "Parsing schema description ".$schemaPath."\n";
+    echo "Parsing schema description " . $schemaPath . "\n";
     $dbXML = CRM_Core_CodeGen_Util_Xml::parse($schemaPath);
     // print_r( $dbXML );
 
@@ -36,18 +37,18 @@ class CRM_Core_CodeGen_Specification {
     $this->tables = $this->orderTables($this->tables);
 
     // add archive tables here
-    $archiveTables = array( );
-    foreach ($this->tables as $name => $table ) {
-      if ( $table['archive'] == 'true' ) {
+    $archiveTables = array();
+    foreach ($this->tables as $name => $table) {
+      if ($table['archive'] == 'true') {
         $name = 'archive_' . $table['name'];
         $table['name'] = $name;
         $table['archive'] = 'false';
-        if ( isset($table['foreignKey']) ) {
+        if (isset($table['foreignKey'])) {
           foreach ($table['foreignKey'] as $fkName => $fkValue) {
             if ($this->tables[$fkValue['table']]['archive'] == 'true') {
               $table['foreignKey'][$fkName]['table'] = 'archive_' . $table['foreignKey'][$fkName]['table'];
               $table['foreignKey'][$fkName]['uniqName'] =
-                str_replace( 'FK_', 'FK_archive_', $table['foreignKey'][$fkName]['uniqName'] );
+                str_replace('FK_', 'FK_archive_', $table['foreignKey'][$fkName]['uniqName']);
             }
           }
           $archiveTables[$name] = $table;
@@ -301,7 +302,8 @@ class CRM_Core_CodeGen_Specification {
         $field['rows'] = isset($fieldXML->html) ? $this->value('rows', $fieldXML->html) : NULL;
         $field['cols'] = isset($fieldXML->html) ? $this->value('cols', $fieldXML->html) : NULL;
         break;
-        break;
+
+      break;
 
       case 'datetime':
         $field['sqlType'] = $field['phpType'] = $type;
@@ -375,13 +377,13 @@ class CRM_Core_CodeGen_Specification {
       );
       $field['html'] = array();
       foreach ($validOptions as $htmlOption) {
-        if(!empty($fieldXML->html->$htmlOption)){
+        if (!empty($fieldXML->html->$htmlOption)) {
           $field['html'][$htmlOption] = $this->value($htmlOption, $fieldXML->html);
         }
       }
     }
     $field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML);
-    if(!empty($field['pseudoconstant'])){
+    if (!empty($field['pseudoconstant'])) {
       //ok this is a bit long-winded but it gets there & is consistent with above approach
       $field['pseudoconstant'] = array();
       $validOptions = array(
@@ -400,7 +402,7 @@ class CRM_Core_CodeGen_Specification {
         'callback',
       );
       foreach ($validOptions as $pseudoOption) {
-        if(!empty($fieldXML->pseudoconstant->$pseudoOption)){
+        if (!empty($fieldXML->pseudoconstant->$pseudoOption)) {
           $field['pseudoconstant'][$pseudoOption] = $this->value($pseudoOption, $fieldXML->pseudoconstant);
         }
       }
@@ -450,7 +452,7 @@ class CRM_Core_CodeGen_Specification {
 
     /** need to make sure there is a field of type name */
     if (!array_key_exists($name, $fields)) {
-        echo "primary key $name in $table->name does not have a field definition, ignoring\n";
+      echo "primary key $name in $table->name does not have a field definition, ignoring\n";
       return;
     }
 
@@ -475,14 +477,14 @@ class CRM_Core_CodeGen_Specification {
 
     $index = array();
     // empty index name is fine
-    $indexName      = trim((string)$indexXML->name);
+    $indexName      = trim((string) $indexXML->name);
     $index['name']  = $indexName;
     $index['field'] = array();
 
     // populate fields
     foreach ($indexXML->fieldName as $v) {
-      $fieldName = (string)($v);
-      $length = (string)($v['length']);
+      $fieldName = (string) ($v);
+      $length = (string) ($v['length']);
       if (strlen($length) > 0) {
         $fieldName = "$fieldName($length)";
       }
@@ -541,7 +543,7 @@ class CRM_Core_CodeGen_Specification {
 
     /** need to make sure there is a field of type name */
     if (!array_key_exists($name, $fields)) {
-        echo "foreign $name in $currentTableName does not have a field definition, ignoring\n";
+      echo "foreign $name in $currentTableName does not have a field definition, ignoring\n";
       return;
     }