Test Failed
Push — master ( b381e6...5958d3 )
by Björn
02:48 queued 12s
created
src/Application/Controller/Traits/ControllerActiontitlesTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      */
23 23
     public function getActionTitles() 
24 24
     {
25
-        return $this->actionTitles ;
25
+        return $this->actionTitles;
26 26
     }
27 27
 
28 28
     /**
Please login to merge, or discard this patch.
Application/src/Application/Controller/Traits/ControllerToolbarTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      */
23 23
     public function getToolbarItems() 
24 24
     {
25
-        return $this->toolbarItems ;
25
+        return $this->toolbarItems;
26 26
     }
27 27
     
28 28
     /**
Please login to merge, or discard this patch.
Application/src/Application/Controller/Traits/ControllerTranslatorTrait.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
  */
23 23
 trait ControllerTranslatorTrait {
24 24
 
25
-	/**
25
+    /**
26 26
      * 
27 27
      * @var \Zend\I18n\Translator\Translator
28 28
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
      */
65 65
     public function translate($message, $textdomain = 'default', $locale = null) 
66 66
     {
67
-        return ( $this->getTranslator()->translate($message, $textdomain, $locale) );
67
+        return ($this->getTranslator()->translate($message, $textdomain, $locale));
68 68
     }
69 69
     
70 70
 }
Please login to merge, or discard this patch.
module/Application/src/Application/Controller/BaseActionController.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class BaseActionController extends AbstractActionController implements Dispatchable
36 36
 {
37
-	//use ServiceLocatorAwareTrait;
38
-	use ControllerTranslatorTrait;
39
-	use ControllerActiontitlesTrait;
40
-	use ControllerToolbarTrait;
37
+    //use ServiceLocatorAwareTrait;
38
+    use ControllerTranslatorTrait;
39
+    use ControllerActiontitlesTrait;
40
+    use ControllerToolbarTrait;
41 41
     
42 42
     //protected $serviceLocator;
43 43
     
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function __construct( ServiceLocatorInterface $serviceLocator )
50 50
     {
51
-    	if ( $serviceLocator ) {
52
-    		$this->setServiceLocator($serviceLocator);
53
-    	}
51
+        if ( $serviceLocator ) {
52
+            $this->setServiceLocator($serviceLocator);
53
+        }
54 54
     }
55 55
     
56 56
     /**
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function isXHR()
149 149
     {
150
-    	/**
151
-    	 * @var \Zend\Http\PhpEnvironment\Request|\Zend\Http\Request $request
152
-    	 */
153
-    	$request = $this->getRequest();
154
-    	if ( 
155
-    		($request instanceof \Zend\Http\PhpEnvironment\Request) ||
156
-    		($request instanceof \Zend\Http\Request) 
157
-    	) {
158
-    		return ( $request->isXmlHttpRequest() );
159
-    	}
160
-    	return (false);
150
+        /**
151
+         * @var \Zend\Http\PhpEnvironment\Request|\Zend\Http\Request $request
152
+         */
153
+        $request = $this->getRequest();
154
+        if ( 
155
+            ($request instanceof \Zend\Http\PhpEnvironment\Request) ||
156
+            ($request instanceof \Zend\Http\Request) 
157
+        ) {
158
+            return ( $request->isXmlHttpRequest() );
159
+        }
160
+        return (false);
161 161
     }
162 162
     
163 163
     /**
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * basic constructor injecting global service manager/locator
47 47
      * @return self
48 48
      */
49
-    public function __construct( ServiceLocatorInterface $serviceLocator )
49
+    public function __construct(ServiceLocatorInterface $serviceLocator)
50 50
     {
51
-    	if ( $serviceLocator ) {
51
+    	if ($serviceLocator) {
52 52
     		$this->setServiceLocator($serviceLocator);
53 53
     	}
54 54
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     {
135 135
 
136 136
         $oAuth = $this->getServiceLocator()->get('zfcuser_auth_service');
137
-        if ($oAuth->hasIdentity() ) {
137
+        if ($oAuth->hasIdentity()) {
138 138
             return $oAuth->getIdentity();
139 139
         }
140 140
         return null;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     		($request instanceof \Zend\Http\PhpEnvironment\Request) ||
156 156
     		($request instanceof \Zend\Http\Request) 
157 157
     	) {
158
-    		return ( $request->isXmlHttpRequest() );
158
+    		return ($request->isXmlHttpRequest());
159 159
     	}
160 160
     	return (false);
161 161
     }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @param array $vars [optional] additional variables
180 180
      * @return array
181 181
      */
182
-    public function getTemplateVars( $vars = array() ) 
182
+    public function getTemplateVars($vars = array()) 
183 183
     {
184 184
         $result = (array_merge( 
185 185
             $this->params()->fromRoute(), 
Please login to merge, or discard this patch.
module/Application/src/Application/Model/DbStructUpdater.php 4 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
     var $config = array();//updater configuration
61 61
 
62 62
     /**
63
-    * Constructor
63
+     * Constructor
64 64
      *
65
-    * @access public
66
-    */
65
+     * @access public
66
+     */
67 67
     public function __construct()
68 68
     {
69 69
         $this->init();
70 70
     }
71 71
 
72 72
     /**
73
-    * Constructor
73
+     * Constructor
74 74
      *
75
-    * @access public
76
-    */
75
+     * @access public
76
+     */
77 77
     public function dbStructUpdater()
78 78
     {
79 79
         $this->init();
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
     }
97 97
 
98 98
     /**
99
-    * merges current updater config with the given one
99
+     * merges current updater config with the given one
100 100
      *
101
-    * @param assoc_array $config new configuration values
102
-    */
101
+     * @param assoc_array $config new configuration values
102
+     */
103 103
     public function setConfig($config=array())
104 104
     {
105 105
         if (is_array($config)) {
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
     }
109 109
 
110 110
     /**
111
-    * Returns array of update SQL with default options, $source, $dest - database structures
111
+     * Returns array of update SQL with default options, $source, $dest - database structures
112 112
      *
113
-    * @access public
114
-    * @param  string $source   structure dump of database to update
115
-    * @param  string $dest     structure dump of the reference database
116
-    * @param  bool   $asString if true - result will be a string, otherwise - array
117
-    * @return array|string update sql statements - in array or string (separated with ';')
118
-    */
113
+     * @access public
114
+     * @param  string $source   structure dump of database to update
115
+     * @param  string $dest     structure dump of the reference database
116
+     * @param  bool   $asString if true - result will be a string, otherwise - array
117
+     * @return array|string update sql statements - in array or string (separated with ';')
118
+     */
119 119
     public function getUpdates($source, $dest, $asString=false)
120 120
     {
121 121
         $result = $asString?'':array();
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
     }
136 136
 
137 137
     /**
138
-    * Filters comparison result and lefts only sync actions allowed by 'updateTypes' option
139
-    */
138
+     * Filters comparison result and lefts only sync actions allowed by 'updateTypes' option
139
+     */
140 140
     public function filterDiffs($compRes)
141 141
     {
142 142
         $result = array();
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
     }
186 186
     
187 187
     /**
188
-    * Gets structured general info about the databases diff :
189
-    * array(sourceOrphans=>array(...), destOrphans=>array(...), different=>array(...))
190
-    */
188
+     * Gets structured general info about the databases diff :
189
+     * array(sourceOrphans=>array(...), destOrphans=>array(...), different=>array(...))
190
+     */
191 191
     public function getDiffInfo($compRes)
192 192
     {        
193 193
         if (!is_array($compRes)) {
@@ -211,20 +211,20 @@  discard block
 block discarded – undo
211 211
     }
212 212
 
213 213
     /**
214
-    * Makes comparison of the given database structures, support some options
214
+     * Makes comparison of the given database structures, support some options
215 215
      *
216
-    * @access private
217
-    * @param  string $source and $dest are strings - database tables structures
218
-    * @return array
219
-    * - table (array)
220
-    *        - destOrphan (boolean)
221
-    *        - sourceOrphan (boolean)
222
-    *        - differs (array) OR (boolean) false if no diffs
223
-    *            - [0](array)
224
-    *                - source (string) structure definition line in the out-of-date table
225
-    *                - dest (string) structure definition line in the reference table
226
-    *            - [1](array) ...
227
-    */
216
+     * @access private
217
+     * @param  string $source and $dest are strings - database tables structures
218
+     * @return array
219
+     * - table (array)
220
+     *        - destOrphan (boolean)
221
+     *        - sourceOrphan (boolean)
222
+     *        - differs (array) OR (boolean) false if no diffs
223
+     *            - [0](array)
224
+     *                - source (string) structure definition line in the out-of-date table
225
+     *                - dest (string) structure definition line in the reference table
226
+     *            - [1](array) ...
227
+     */
228 228
     private function compare($source, $dest)
229 229
     {
230 230
         $this->sourceStruct = $source;
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
     }
271 271
 
272 272
     /**
273
-    * Retrieves list of table names from the database structure dump
273
+     * Retrieves list of table names from the database structure dump
274 274
      *
275
-    * @access private
276
-    * @param  string $struct database structure listing
277
-    */
275
+     * @access private
276
+     * @param  string $struct database structure listing
277
+     */
278 278
     private function getTableList($struct)
279 279
     {
280 280
         $result = array();
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
     }
289 289
 
290 290
     /**
291
-    * Retrieves table structure definition from the database structure dump
291
+     * Retrieves table structure definition from the database structure dump
292 292
      *
293
-    * @access private
294
-    * @param  string $struct         database structure listing
295
-    * @param  string $tab            table name
296
-    * @param  bool   $removeDatabase - either to remove database name in "CREATE TABLE database.tab"-like declarations
297
-    * @return string table structure definition
298
-    */
293
+     * @access private
294
+     * @param  string $struct         database structure listing
295
+     * @param  string $tab            table name
296
+     * @param  bool   $removeDatabase - either to remove database name in "CREATE TABLE database.tab"-like declarations
297
+     * @return string table structure definition
298
+     */
299 299
     private function getTabSql($struct, $tab, $removeDatabase=true)
300 300
     {
301 301
         $result = '';
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
     }
324 324
     
325 325
     /**
326
-    * Splits table sql into indexed array
327
-    */
326
+     * Splits table sql into indexed array
327
+     */
328 328
     public function splitTabSql($sql)
329 329
     {
330 330
         $result = array();
@@ -365,18 +365,18 @@  discard block
 block discarded – undo
365 365
     }
366 366
 
367 367
     /**
368
-    * returns array of fields or keys definitions that differs in the given tables structure
368
+     * returns array of fields or keys definitions that differs in the given tables structure
369 369
      *
370
-    * @access private
371
-    * @param  sring $sourceSql table structure
372
-    * @param  sring $destSql   right table structure supports some $options
373
-    * supports some $options
374
-    * @return array
375
-    *     - [0]
376
-    *         - source (string) out-of-date table field definition
377
-    *         - dest (string) reference table field definition
378
-    *     - [1]...
379
-    */
370
+     * @access private
371
+     * @param  sring $sourceSql table structure
372
+     * @param  sring $destSql   right table structure supports some $options
373
+     * supports some $options
374
+     * @return array
375
+     *     - [0]
376
+     *         - source (string) out-of-date table field definition
377
+     *         - dest (string) reference table field definition
378
+     *     - [1]...
379
+     */
380 380
     private function compareSql($sourceSql, $destSql)//$sourceSql, $destSql
381 381
     {
382 382
         $result = array();        
@@ -439,14 +439,14 @@  discard block
 block discarded – undo
439 439
     }
440 440
 
441 441
     /**
442
-    * Transforms table structure defnition line into key=>value pair where the key is a string that uniquely
443
-    * defines field or key desribed
442
+     * Transforms table structure defnition line into key=>value pair where the key is a string that uniquely
443
+     * defines field or key desribed
444 444
      *
445
-    * @access private
446
-    * @param  string $line field definition string
447
-    * @return array array with single key=>value pair as described in the description
448
-    * implements some options
449
-    */
445
+     * @access private
446
+     * @param  string $line field definition string
447
+     * @return array array with single key=>value pair as described in the description
448
+     * implements some options
449
+     */
450 450
     private function processLine($line)
451 451
     {
452 452
         $options = $this->config;
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
     }
485 485
 
486 486
     /**
487
-    * Takes an output of compare() method to generate the set of sql needed to update source table to make it
488
-    * look as a destination one
487
+     * Takes an output of compare() method to generate the set of sql needed to update source table to make it
488
+     * look as a destination one
489 489
      *
490
-    * @access private
491
-    * @param  array $diff compare() method output
492
-    * @return array list of sql statements
493
-    * supports query generation options
494
-    */
490
+     * @access private
491
+     * @param  array $diff compare() method output
492
+     * @return array list of sql statements
493
+     * supports query generation options
494
+     */
495 495
     private function getDiffSql($diff)//maybe add option to ommit or force 'IF NOT EXISTS', skip autoincrement
496 496
     {
497 497
         $options = $this->config;
@@ -548,14 +548,14 @@  discard block
 block discarded – undo
548 548
     }
549 549
 
550 550
     /**
551
-    * Compiles update sql
551
+     * Compiles update sql
552 552
      *
553
-    * @access private
554
-    * @param  string $action - 'drop', 'add' or 'modify'
555
-    * @param  string $tab    table name
556
-    * @param  string $sql    definition of the element to change
557
-    * @return string update sql
558
-    */
553
+     * @access private
554
+     * @param  string $action - 'drop', 'add' or 'modify'
555
+     * @param  string $tab    table name
556
+     * @param  string $sql    definition of the element to change
557
+     * @return string update sql
558
+     */
559 559
     private function getActionSql($action, $tab, $sql)
560 560
     {
561 561
         $result = 'ALTER TABLE `'.$tab.'` ';
@@ -621,14 +621,14 @@  discard block
 block discarded – undo
621 621
     }
622 622
 
623 623
     /**
624
-    * Searches for the position of the next delimiter which is not inside string literal like 'this ; ' or
625
-    * like "this ; ".
626
-    *
627
-    * Handles escaped \" and \'. Also handles sql comments.
628
-    * Actualy it is regex-based Finit State Machine (FSN)
629
-    *
630
-    * $skipInBrackets - if true, delimiter will be skipped if located inside (brackets) which are not string literals or comment parts
631
-    */
624
+     * Searches for the position of the next delimiter which is not inside string literal like 'this ; ' or
625
+     * like "this ; ".
626
+     *
627
+     * Handles escaped \" and \'. Also handles sql comments.
628
+     * Actualy it is regex-based Finit State Machine (FSN)
629
+     *
630
+     * $skipInBrackets - if true, delimiter will be skipped if located inside (brackets) which are not string literals or comment parts
631
+     */
632 632
     public function getDelimPos($string, $offset=0, $delim=';', $skipInBrackets=false)
633 633
     {
634 634
         $stack = array();
@@ -701,9 +701,9 @@  discard block
 block discarded – undo
701 701
     }
702 702
     
703 703
     /**
704
-    * works the same as getDelimPos except returns position of the first occurence of the delimiter starting from
705
-    * the end of the string
706
-    */
704
+     * works the same as getDelimPos except returns position of the first occurence of the delimiter starting from
705
+     * the end of the string
706
+     */
707 707
     public function getDelimRpos($string, $offset=0, $delim=';', $skipInBrackets=false)
708 708
     {
709 709
         $pos = $this->getDelimPos($string, $offset, $delim, $skipInBrackets);
Please login to merge, or discard this patch.
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -568,39 +568,39 @@
 block discarded – undo
568 568
             $fields = trim($m[3]);
569 569
             switch($action)
570 570
             {
571
-            case 'drop':
572
-                if ($type=='primary') {
573
-                    $result.= 'DROP PRIMARY KEY';
574
-                }
575
-                else
576
-                {
577
-                    $result.= 'DROP INDEX `'.$name.'`';
578
-                }
579
-                break;
580
-            case 'add':
581
-                if ($type=='primary') {
582
-                    $result.= 'ADD PRIMARY KEY '.$fields;
583
-                }
584
-                elseif ($type=='') {
585
-                    $result.= 'ADD INDEX `'.$name.'` '.$fields;
586
-                }
587
-                else
588
-                {
589
-                    $result .='ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
590
-                }
591
-                break;
592
-            case 'modify':
593
-                if ($type=='primary') {
594
-                    $result.='DROP PRIMARY KEY, ADD PRIMARY KEY '.$fields;
595
-                }
596
-                elseif ($type=='') {
597
-                    $result.='DROP INDEX `'.$name.'`, ADD INDEX `'.$name.'` '.$fields;
598
-                }
599
-                else
600
-                {
601
-                    $result.='DROP INDEX `'.$name.'`, ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
602
-                }
603
-                break;
571
+                case 'drop':
572
+                    if ($type=='primary') {
573
+                        $result.= 'DROP PRIMARY KEY';
574
+                    }
575
+                    else
576
+                    {
577
+                        $result.= 'DROP INDEX `'.$name.'`';
578
+                    }
579
+                    break;
580
+                case 'add':
581
+                    if ($type=='primary') {
582
+                        $result.= 'ADD PRIMARY KEY '.$fields;
583
+                    }
584
+                    elseif ($type=='') {
585
+                        $result.= 'ADD INDEX `'.$name.'` '.$fields;
586
+                    }
587
+                    else
588
+                    {
589
+                        $result .='ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
590
+                    }
591
+                    break;
592
+                case 'modify':
593
+                    if ($type=='primary') {
594
+                        $result.='DROP PRIMARY KEY, ADD PRIMARY KEY '.$fields;
595
+                    }
596
+                    elseif ($type=='') {
597
+                        $result.='DROP INDEX `'.$name.'`, ADD INDEX `'.$name.'` '.$fields;
598
+                    }
599
+                    else
600
+                    {
601
+                        $result.='DROP INDEX `'.$name.'`, ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
602
+                    }
603
+                    break;
604 604
 
605 605
             }
606 606
         }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 */
56 56
 class DbStructUpdater
57 57
 {
58
-    var $sourceStruct = '';//structure dump of the reference database
59
-    var $destStruct = '';//structure dump of database to update
60
-    var $config = array();//updater configuration
58
+    var $sourceStruct = ''; //structure dump of the reference database
59
+    var $destStruct = ''; //structure dump of database to update
60
+    var $config = array(); //updater configuration
61 61
 
62 62
     /**
63 63
     * Constructor
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      *
101 101
     * @param assoc_array $config new configuration values
102 102
     */
103
-    public function setConfig($config=array())
103
+    public function setConfig($config = array())
104 104
     {
105 105
         if (is_array($config)) {
106 106
             $this->config = array_merge($this->config, $config);
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
     * @param  bool   $asString if true - result will be a string, otherwise - array
117 117
     * @return array|string update sql statements - in array or string (separated with ';')
118 118
     */
119
-    public function getUpdates($source, $dest, $asString=false)
119
+    public function getUpdates($source, $dest, $asString = false)
120 120
     {
121
-        $result = $asString?'':array();
121
+        $result = $asString ? '' : array();
122 122
         $compRes = $this->compare($source, $dest);
123 123
         if (empty($compRes)) {
124 124
             return $result;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         }
150 150
         $allowedActions = array('create', 'drop', 'add', 'remove', 'modify');
151 151
         $updateActions = array_intersect($updateActions, $allowedActions);
152
-        foreach($compRes as $table=>$info)
152
+        foreach ($compRes as $table=>$info)
153 153
         {
154 154
             if ($info['sourceOrphan']) {
155 155
                 if (in_array('create', $updateActions)) {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                     $result[$table] = $info;
162 162
                 }
163 163
             }
164
-            elseif($info['differs']) {
164
+            elseif ($info['differs']) {
165 165
                 $resultInfo = $info;
166 166
                 unset($resultInfo['differs']);
167 167
                 foreach ($info['differs'] as $diff)
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                     elseif (empty($diff['source']) && in_array('remove', $updateActions)) {
173 173
                         $resultInfo['differs'][] = $diff;
174 174
                     }
175
-                    elseif(in_array('modify', $updateActions)) {
175
+                    elseif (in_array('modify', $updateActions)) {
176 176
                         $resultInfo['differs'][] = $diff;
177 177
                     }
178 178
                 }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             return false;
195 195
         }
196 196
         $result = array('sourceOrphans'=>array(), 'destOrphans'=>array(), 'different'=>array());
197
-        foreach($compRes as $table=>$info)
197
+        foreach ($compRes as $table=>$info)
198 198
         {
199 199
             if ($info['sourceOrphan']) {
200 200
                 $result['sourceOrphans'][] = $table;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         foreach ($all as $tab)
243 243
         {
244 244
             $info = array('destOrphan'=>false, 'sourceOrphan'=>false, 'differs'=>false);
245
-            if(in_array($tab, $destOrphans)) {
245
+            if (in_array($tab, $destOrphans)) {
246 246
                 $info['destOrphan'] = true;
247 247
             }
248 248
             elseif (in_array($tab, $sourceOrphans)) {
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                 $destSql = $this->getTabSql($this->destStruct, $tab, true);
254 254
                 $sourceSql = $this->getTabSql($this->sourceStruct, $tab, true);
255 255
                 $diffs = $this->compareSql($sourceSql, $destSql);                
256
-                if ($diffs===false) {
256
+                if ($diffs === false) {
257 257
                     trigger_error('[WARNING] error parsing definition of table "'.$tab.'" - skipped');
258 258
                     continue;
259 259
                 }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 {
262 262
                     $info['differs'] = $diffs;                    
263 263
                 }                
264
-                else { continue;//empty array
264
+                else { continue; //empty array
265 265
                 }         
266 266
             }
267 267
             $result[$tab] = $info;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     {
280 280
         $result = array();
281 281
         if (preg_match_all('/CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?(?:`?(\w+)`?\.)?`?(\w+)`?/i', $struct, $m)) {
282
-            foreach($m[2] as $match)//m[1] is a database name if any
282
+            foreach ($m[2] as $match)//m[1] is a database name if any
283 283
             {
284 284
                 $result[] = $match;
285 285
             }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     * @param  bool   $removeDatabase - either to remove database name in "CREATE TABLE database.tab"-like declarations
297 297
     * @return string table structure definition
298 298
     */
299
-    private function getTabSql($struct, $tab, $removeDatabase=true)
299
+    private function getTabSql($struct, $tab, $removeDatabase = true)
300 300
     {
301 301
         $result = '';
302 302
         /* create table should be single line in this case*/
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
             $tableDef = $m[0][0];
306 306
             $start = $m[0][1];
307 307
             $database = $m[2][0];
308
-            $offset = $start+strlen($m[0][0]);
308
+            $offset = $start + strlen($m[0][0]);
309 309
             $end = $this->getDelimPos($struct, $offset);
310 310
             if ($end === false) {
311 311
                 $result = substr($struct, $start);
312 312
             }
313 313
             else
314 314
             {
315
-                $result = substr($struct, $start, $end-$start);//already without ';'
315
+                $result = substr($struct, $start, $end - $start); //already without ';'
316 316
             }
317 317
         }
318 318
         $result = trim($result);
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
         $result = array();
331 331
         //find opening bracket, get the prefix along with it
332 332
         $openBracketPos = $this->getDelimPos($sql, 0, '(');
333
-        if ($openBracketPos===false) {
333
+        if ($openBracketPos === false) {
334 334
             trigger_error('[WARNING] can not find opening bracket in table definition');
335 335
             return false;
336 336
         }
337
-        $prefix = substr($sql, 0, $openBracketPos+1);//prefix can not be empty, so do not check it, just trim
337
+        $prefix = substr($sql, 0, $openBracketPos + 1); //prefix can not be empty, so do not check it, just trim
338 338
         $result[] = trim($prefix);
339
-        $body = substr($sql, strlen($prefix));//fields, indexes and part after closing bracket
339
+        $body = substr($sql, strlen($prefix)); //fields, indexes and part after closing bracket
340 340
         //split by commas, get part by part
341
-        while(($commaPos = $this->getDelimPos($body, 0, ',', true))!==false)
341
+        while (($commaPos = $this->getDelimPos($body, 0, ',', true)) !== false)
342 342
         {
343
-            $part = trim(substr($body, 0, $commaPos+1));//read another part and shorten $body
343
+            $part = trim(substr($body, 0, $commaPos + 1)); //read another part and shorten $body
344 344
             if ($part) {
345 345
                 $result[] = $part;
346 346
             }
347
-            $body = substr($body, $commaPos+1);
347
+            $body = substr($body, $commaPos + 1);
348 348
         }
349 349
         //here we have last field (or index) definition + part after closing bracket (ENGINE, ect)
350 350
         $closeBracketPos = $this->getDelimRpos($body, 0, ')');
351
-        if ($closeBracketPos===false) {
351
+        if ($closeBracketPos === false) {
352 352
             trigger_error('[WARNING] can not find closing bracket in table definition');
353 353
             return false;
354 354
         }
@@ -381,27 +381,27 @@  discard block
 block discarded – undo
381 381
     {
382 382
         $result = array();        
383 383
         //split with comma delimiter, not line breaks
384
-        $sourceParts =  $this->splitTabSql($sourceSql);
385
-        if ($sourceParts===false)//error parsing sql
384
+        $sourceParts = $this->splitTabSql($sourceSql);
385
+        if ($sourceParts === false)//error parsing sql
386 386
         {
387 387
             trigger_error('[WARNING] error parsing source sql');
388 388
             return false;
389 389
         }
390 390
         $destParts = $this->splitTabSql($destSql);
391
-        if ($destParts===false) {
391
+        if ($destParts === false) {
392 392
             trigger_error('[WARNING] error parsing destination sql');
393 393
             return false;
394 394
         }
395 395
         $sourcePartsIndexed = array();
396 396
         $destPartsIndexed = array();
397
-        foreach($sourceParts as $line)
397
+        foreach ($sourceParts as $line)
398 398
         {            
399 399
             $lineInfo = $this->processLine($line);
400 400
             if (!$lineInfo) { continue; 
401 401
             }
402 402
             $sourcePartsIndexed[$lineInfo['key']] = $lineInfo['line'];
403 403
         }
404
-        foreach($destParts as $line)
404
+        foreach ($destParts as $line)
405 405
         {            
406 406
             $lineInfo = $this->processLine($line);
407 407
             if (!$lineInfo) { continue; 
@@ -411,16 +411,16 @@  discard block
 block discarded – undo
411 411
         $sourceKeys = array_keys($sourcePartsIndexed);
412 412
         $destKeys = array_keys($destPartsIndexed);
413 413
         $all = array_unique(array_merge($sourceKeys, $destKeys));
414
-        sort($all);//fields first, then indexes - because fields are prefixed with '!'
414
+        sort($all); //fields first, then indexes - because fields are prefixed with '!'
415 415
 
416 416
         foreach ($all as $key)
417 417
         {
418 418
             $info = array('source'=>'', 'dest'=>'');
419
-            $inSource= in_array($key, $sourceKeys);
420
-            $inDest= in_array($key, $destKeys);
419
+            $inSource = in_array($key, $sourceKeys);
420
+            $inDest = in_array($key, $destKeys);
421 421
             $sourceOrphan = $inSource && !$inDest;
422 422
             $destOrphan = $inDest && !$inSource;
423
-            $different =  $inSource && $inDest && $destPartsIndexed[$key]!=$sourcePartsIndexed[$key];
423
+            $different = $inSource && $inDest && $destPartsIndexed[$key] != $sourcePartsIndexed[$key];
424 424
             if ($sourceOrphan) {
425 425
                 $info['source'] = $sourcePartsIndexed[$key];
426 426
             }
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
         }
463 463
         elseif (preg_match('/^`?\w+`?/i', $line, $m))//field definition
464 464
         {
465
-            $key = '!'.$m[0];//to make sure fields will be synchronised before the keys
465
+            $key = '!'.$m[0]; //to make sure fields will be synchronised before the keys
466 466
         }
467 467
         else
468 468
         {
469
-            return false;//line has no valuable info (empty or comment)
469
+            return false; //line has no valuable info (empty or comment)
470 470
         }
471 471
         //$key = str_replace('`', '', $key);
472 472
         if (!empty($options['varcharDefaultIgnore'])) {
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
             $line = preg_replace("/ AUTO_INCREMENT=[0-9]+/i", '', $line);
480 480
         }
481 481
         $result['key'] = $key;
482
-        $result['line']= $line;
482
+        $result['line'] = $line;
483 483
         return $result;
484 484
     }
485 485
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
         if (!is_array($diff) || empty($diff)) {
500 500
             return $sqls;
501 501
         }
502
-        foreach($diff as $tab=>$info)
502
+        foreach ($diff as $tab=>$info)
503 503
         {
504 504
             if ($info['sourceOrphan'])//delete it
505 505
             {
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
             }
523 523
             else
524 524
             {
525
-                foreach($info['differs'] as $finfo)
525
+                foreach ($info['differs'] as $finfo)
526 526
                 {
527 527
                     $inDest = !empty($finfo['dest']);
528 528
                     $inSource = !empty($finfo['source']);
@@ -560,45 +560,45 @@  discard block
 block discarded – undo
560 560
     {
561 561
         $result = 'ALTER TABLE `'.$tab.'` ';
562 562
         $action = strtolower($action);
563
-        $keyField = '`?\w`?(?:\(\d+\))?';//matches `name`(10)
564
-        $keyFieldList = '(?:'.$keyField.'(?:,\s?)?)+';//matches `name`(10),`desc`(255)
563
+        $keyField = '`?\w`?(?:\(\d+\))?'; //matches `name`(10)
564
+        $keyFieldList = '(?:'.$keyField.'(?:,\s?)?)+'; //matches `name`(10),`desc`(255)
565 565
         if (preg_match('/((?:PRIMARY )|(?:UNIQUE )|(?:FULLTEXT ))?KEY `?(\w+)?`?\s(\('.$keyFieldList.'\))/i', $sql, $m)) {   //key and index operations
566 566
             $type = strtolower(trim($m[1]));
567 567
             $name = trim($m[2]);
568 568
             $fields = trim($m[3]);
569
-            switch($action)
569
+            switch ($action)
570 570
             {
571 571
             case 'drop':
572
-                if ($type=='primary') {
573
-                    $result.= 'DROP PRIMARY KEY';
572
+                if ($type == 'primary') {
573
+                    $result .= 'DROP PRIMARY KEY';
574 574
                 }
575 575
                 else
576 576
                 {
577
-                    $result.= 'DROP INDEX `'.$name.'`';
577
+                    $result .= 'DROP INDEX `'.$name.'`';
578 578
                 }
579 579
                 break;
580 580
             case 'add':
581
-                if ($type=='primary') {
582
-                    $result.= 'ADD PRIMARY KEY '.$fields;
581
+                if ($type == 'primary') {
582
+                    $result .= 'ADD PRIMARY KEY '.$fields;
583 583
                 }
584
-                elseif ($type=='') {
585
-                    $result.= 'ADD INDEX `'.$name.'` '.$fields;
584
+                elseif ($type == '') {
585
+                    $result .= 'ADD INDEX `'.$name.'` '.$fields;
586 586
                 }
587 587
                 else
588 588
                 {
589
-                    $result .='ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
589
+                    $result .= 'ADD '.strtoupper($type).' `'.$name.'` '.$fields; //fulltext or unique
590 590
                 }
591 591
                 break;
592 592
             case 'modify':
593
-                if ($type=='primary') {
594
-                    $result.='DROP PRIMARY KEY, ADD PRIMARY KEY '.$fields;
593
+                if ($type == 'primary') {
594
+                    $result .= 'DROP PRIMARY KEY, ADD PRIMARY KEY '.$fields;
595 595
                 }
596
-                elseif ($type=='') {
597
-                    $result.='DROP INDEX `'.$name.'`, ADD INDEX `'.$name.'` '.$fields;
596
+                elseif ($type == '') {
597
+                    $result .= 'DROP INDEX `'.$name.'`, ADD INDEX `'.$name.'` '.$fields;
598 598
                 }
599 599
                 else
600 600
                 {
601
-                    $result.='DROP INDEX `'.$name.'`, ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
601
+                    $result .= 'DROP INDEX `'.$name.'`, ADD '.strtoupper($type).' `'.$name.'` '.$fields; //fulltext or unique
602 602
                 }
603 603
                 break;
604 604
 
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
         else //fields operations
608 608
         {
609 609
             $sql = rtrim(trim($sql), ',');
610
-            $result.= strtoupper($action);
611
-            if ($action=='drop') {
610
+            $result .= strtoupper($action);
611
+            if ($action == 'drop') {
612 612
                 $spacePos = strpos($sql, ' ');
613
-                $result.= ' '.substr($sql, 0, $spacePos);
613
+                $result .= ' '.substr($sql, 0, $spacePos);
614 614
             }
615 615
             else
616 616
             {
617
-                $result.= ' '.$sql;
617
+                $result .= ' '.$sql;
618 618
             }
619 619
         }
620 620
         return $result;
@@ -629,34 +629,34 @@  discard block
 block discarded – undo
629 629
     *
630 630
     * $skipInBrackets - if true, delimiter will be skipped if located inside (brackets) which are not string literals or comment parts
631 631
     */
632
-    public function getDelimPos($string, $offset=0, $delim=';', $skipInBrackets=false)
632
+    public function getDelimPos($string, $offset = 0, $delim = ';', $skipInBrackets = false)
633 633
     {
634 634
         $stack = array();
635
-        $rbs = '\\\\';    //reg - escaped backslash
635
+        $rbs = '\\\\'; //reg - escaped backslash
636 636
         $regPrefix = "(?<!$rbs)(?:$rbs{2})*";
637 637
         $reg = $regPrefix.'("|\')|(/\\*)|(\\*/)|(-- )|(\r\n|\r|\n)|';
638 638
         if ($skipInBrackets) {
639
-            $reg.='(\(|\))|';
639
+            $reg .= '(\(|\))|';
640 640
         }
641 641
         else 
642 642
         {
643
-            $reg.='()';
643
+            $reg .= '()';
644 644
         }
645 645
         $reg .= '('.preg_quote($delim).')';
646 646
         while (preg_match('%'.$reg.'%', $string, $m, PREG_OFFSET_CAPTURE, $offset))
647 647
         {
648
-            $offset = $m[0][1]+strlen($m[0][0]);
649
-            if (end($stack)=='/*') {
648
+            $offset = $m[0][1] + strlen($m[0][0]);
649
+            if (end($stack) == '/*') {
650 650
                 if (!empty($m[3][0])) {
651 651
                     array_pop($stack);
652 652
                 }
653
-                continue;//here we could also simplify regexp
653
+                continue; //here we could also simplify regexp
654 654
             }
655
-            if (end($stack)=='-- ') {
655
+            if (end($stack) == '-- ') {
656 656
                 if (!empty($m[5][0])) {
657 657
                     array_pop($stack);
658 658
                 }
659
-                continue;//here we could also simplify regexp
659
+                continue; //here we could also simplify regexp
660 660
             }
661 661
 
662 662
             if (!empty($m[7][0]))// ';' found
@@ -671,16 +671,16 @@  discard block
 block discarded – undo
671 671
             }
672 672
             if (!empty($m[6][0]))// '(' or ')' found
673 673
             {
674
-                if (empty($stack) && $m[6][0]=='(') {
674
+                if (empty($stack) && $m[6][0] == '(') {
675 675
                     array_push($stack, $m[6][0]);
676 676
                 }
677
-                elseif($m[6][0]==')' && end($stack)=='(') {
677
+                elseif ($m[6][0] == ')' && end($stack) == '(') {
678 678
                     array_pop($stack);
679 679
                 }
680 680
             }
681 681
             elseif (!empty($m[1][0]))// ' or " found
682 682
             {
683
-                if (end($stack)==$m[1][0]) {
683
+                if (end($stack) == $m[1][0]) {
684 684
                     array_pop($stack);
685 685
                 }
686 686
                 else
@@ -704,20 +704,20 @@  discard block
 block discarded – undo
704 704
     * works the same as getDelimPos except returns position of the first occurence of the delimiter starting from
705 705
     * the end of the string
706 706
     */
707
-    public function getDelimRpos($string, $offset=0, $delim=';', $skipInBrackets=false)
707
+    public function getDelimRpos($string, $offset = 0, $delim = ';', $skipInBrackets = false)
708 708
     {
709 709
         $pos = $this->getDelimPos($string, $offset, $delim, $skipInBrackets);
710
-        if ($pos===false) {
710
+        if ($pos === false) {
711 711
             return false;
712 712
         }
713 713
         do
714 714
         {
715
-            $newPos=$this->getDelimPos($string, $pos+1, $delim, $skipInBrackets);
715
+            $newPos = $this->getDelimPos($string, $pos + 1, $delim, $skipInBrackets);
716 716
             if ($newPos !== false) {
717 717
                 $pos = $newPos;
718 718
             }
719 719
         }
720
-        while($newPos!==false);
720
+        while ($newPos !== false);
721 721
         return $pos;
722 722
     }
723 723
 }
Please login to merge, or discard this patch.
Braces   +67 added lines, -75 removed lines patch added patch discarded remove patch
@@ -142,8 +142,7 @@  discard block
 block discarded – undo
142 142
         $result = array();
143 143
         if (is_array($this->config['updateTypes'])) {
144 144
             $updateActions = $this->config['updateTypes'];
145
-        }
146
-        else
145
+        } else
147 146
         {
148 147
             $updateActions = array_map('trim', explode(',', $this->config['updateTypes']));
149 148
         }
@@ -155,24 +154,20 @@  discard block
 block discarded – undo
155 154
                 if (in_array('create', $updateActions)) {
156 155
                     $result[$table] = $info;
157 156
                 }
158
-            }
159
-            elseif ($info['destOrphan']) {
157
+            } elseif ($info['destOrphan']) {
160 158
                 if (in_array('drop', $updateActions)) {
161 159
                     $result[$table] = $info;
162 160
                 }
163
-            }
164
-            elseif($info['differs']) {
161
+            } elseif($info['differs']) {
165 162
                 $resultInfo = $info;
166 163
                 unset($resultInfo['differs']);
167 164
                 foreach ($info['differs'] as $diff)
168 165
                 {
169 166
                     if (empty($diff['dest']) && in_array('add', $updateActions)) {
170 167
                         $resultInfo['differs'][] = $diff;
171
-                    }
172
-                    elseif (empty($diff['source']) && in_array('remove', $updateActions)) {
168
+                    } elseif (empty($diff['source']) && in_array('remove', $updateActions)) {
173 169
                         $resultInfo['differs'][] = $diff;
174
-                    }
175
-                    elseif(in_array('modify', $updateActions)) {
170
+                    } elseif(in_array('modify', $updateActions)) {
176 171
                         $resultInfo['differs'][] = $diff;
177 172
                     }
178 173
                 }
@@ -198,11 +193,9 @@  discard block
 block discarded – undo
198 193
         {
199 194
             if ($info['sourceOrphan']) {
200 195
                 $result['sourceOrphans'][] = $table;
201
-            }
202
-            elseif ($info['destOrphan']) {
196
+            } elseif ($info['destOrphan']) {
203 197
                 $result['destOrphans'][] = $table;
204
-            }
205
-            else
198
+            } else
206 199
             {
207 200
                 $result['different'][] = $table;
208 201
             }
@@ -244,11 +237,9 @@  discard block
 block discarded – undo
244 237
             $info = array('destOrphan'=>false, 'sourceOrphan'=>false, 'differs'=>false);
245 238
             if(in_array($tab, $destOrphans)) {
246 239
                 $info['destOrphan'] = true;
247
-            }
248
-            elseif (in_array($tab, $sourceOrphans)) {
240
+            } elseif (in_array($tab, $sourceOrphans)) {
249 241
                 $info['sourceOrphan'] = true;
250
-            }
251
-            else
242
+            } else
252 243
             {                
253 244
                 $destSql = $this->getTabSql($this->destStruct, $tab, true);
254 245
                 $sourceSql = $this->getTabSql($this->sourceStruct, $tab, true);
@@ -256,12 +247,12 @@  discard block
 block discarded – undo
256 247
                 if ($diffs===false) {
257 248
                     trigger_error('[WARNING] error parsing definition of table "'.$tab.'" - skipped');
258 249
                     continue;
259
-                }
260
-                elseif (!empty($diffs))//not empty array
250
+                } elseif (!empty($diffs)) {
251
+                    //not empty array
261 252
                 {
262
-                    $info['differs'] = $diffs;                    
263
-                }                
264
-                else { continue;//empty array
253
+                    $info['differs'] = $diffs;
254
+                }
255
+                } else { continue;//empty array
265 256
                 }         
266 257
             }
267 258
             $result[$tab] = $info;
@@ -279,10 +270,12 @@  discard block
 block discarded – undo
279 270
     {
280 271
         $result = array();
281 272
         if (preg_match_all('/CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?(?:`?(\w+)`?\.)?`?(\w+)`?/i', $struct, $m)) {
282
-            foreach($m[2] as $match)//m[1] is a database name if any
273
+            foreach($m[2] as $match) {
274
+                //m[1] is a database name if any
283 275
             {
284 276
                 $result[] = $match;
285 277
             }
278
+            }
286 279
         }
287 280
         return $result;
288 281
     }
@@ -309,8 +302,7 @@  discard block
 block discarded – undo
309 302
             $end = $this->getDelimPos($struct, $offset);
310 303
             if ($end === false) {
311 304
                 $result = substr($struct, $start);
312
-            }
313
-            else
305
+            } else
314 306
             {
315 307
                 $result = substr($struct, $start, $end-$start);//already without ';'
316 308
             }
@@ -382,9 +374,11 @@  discard block
 block discarded – undo
382 374
         $result = array();        
383 375
         //split with comma delimiter, not line breaks
384 376
         $sourceParts =  $this->splitTabSql($sourceSql);
385
-        if ($sourceParts===false)//error parsing sql
377
+        if ($sourceParts===false) {
378
+            //error parsing sql
386 379
         {
387 380
             trigger_error('[WARNING] error parsing source sql');
381
+        }
388 382
             return false;
389 383
         }
390 384
         $destParts = $this->splitTabSql($destSql);
@@ -423,15 +417,12 @@  discard block
 block discarded – undo
423 417
             $different =  $inSource && $inDest && $destPartsIndexed[$key]!=$sourcePartsIndexed[$key];
424 418
             if ($sourceOrphan) {
425 419
                 $info['source'] = $sourcePartsIndexed[$key];
426
-            }
427
-            elseif ($destOrphan) {
420
+            } elseif ($destOrphan) {
428 421
                 $info['dest'] = $destPartsIndexed[$key];
429
-            }
430
-            elseif ($different) {
422
+            } elseif ($different) {
431 423
                 $info['source'] = $sourcePartsIndexed[$key];
432 424
                 $info['dest'] = $destPartsIndexed[$key];
433
-            }
434
-            else { continue; 
425
+            } else { continue; 
435 426
             }
436 427
             $result[] = $info;
437 428
         }
@@ -452,19 +443,24 @@  discard block
 block discarded – undo
452 443
         $options = $this->config;
453 444
         $result = array('key'=>'', 'line'=>'');
454 445
         $line = rtrim(trim($line), ',');
455
-        if (preg_match('/^(CREATE TABLE)|(\) ENGINE=)/i', $line))//first or last table definition line
446
+        if (preg_match('/^(CREATE TABLE)|(\) ENGINE=)/i', $line)) {
447
+            //first or last table definition line
456 448
         {
457 449
             return false;
458 450
         }
459
-        if (preg_match('/^(PRIMARY KEY)|(((UNIQUE )|(FULLTEXT ))?KEY `?\w+`?)/i', $line, $m))//key definition
451
+        }
452
+        if (preg_match('/^(PRIMARY KEY)|(((UNIQUE )|(FULLTEXT ))?KEY `?\w+`?)/i', $line, $m)) {
453
+            //key definition
460 454
         {
461 455
             $key = $m[0];
462 456
         }
463
-        elseif (preg_match('/^`?\w+`?/i', $line, $m))//field definition
457
+        } elseif (preg_match('/^`?\w+`?/i', $line, $m)) {
458
+            //field definition
464 459
         {
465
-            $key = '!'.$m[0];//to make sure fields will be synchronised before the keys
460
+            $key = '!'.$m[0];
466 461
         }
467
-        else
462
+        //to make sure fields will be synchronised before the keys
463
+        } else
468 464
         {
469 465
             return false;//line has no valuable info (empty or comment)
470 466
         }
@@ -501,13 +497,16 @@  discard block
 block discarded – undo
501 497
         }
502 498
         foreach($diff as $tab=>$info)
503 499
         {
504
-            if ($info['sourceOrphan'])//delete it
500
+            if ($info['sourceOrphan']) {
501
+                //delete it
505 502
             {
506 503
                 $sqls[] = 'DROP TABLE `'.$tab.'`';
507 504
             }
508
-            elseif ($info['destOrphan'])//create destination table in source
505
+            } elseif ($info['destOrphan']) {
506
+                //create destination table in source
509 507
             {
510 508
                 $database = '';
509
+            }
511 510
                 $destSql = $this->getTabSql($this->destStruct, $tab, $database);
512 511
                 if (!empty($options['ignoreIncrement'])) {
513 512
                     $destSql = preg_replace("/\s*AUTO_INCREMENT=[0-9]+/i", '', $destSql);
@@ -519,8 +518,7 @@  discard block
 block discarded – undo
519 518
                     $destSql = preg_replace('/(CREATE(?:\s*TEMPORARY)?\s*TABLE\s*)(?:IF NOT EXISTS\s*)?(`?\w+`?)/i', '$1IF NOT EXISTS $2', $destSql);
520 519
                 }
521 520
                 $sqls[] = $destSql;
522
-            }
523
-            else
521
+            } else
524 522
             {
525 523
                 foreach($info['differs'] as $finfo)
526 524
                 {
@@ -529,12 +527,10 @@  discard block
 block discarded – undo
529 527
                     if ($inSource && !$inDest) {
530 528
                         $sql = $finfo['source'];
531 529
                         $action = 'drop';
532
-                    }
533
-                    elseif ($inDest && !$inSource) {
530
+                    } elseif ($inDest && !$inSource) {
534 531
                         $sql = $finfo['dest'];
535 532
                         $action = 'add';
536
-                    }
537
-                    else
533
+                    } else
538 534
                     {
539 535
                         $sql = $finfo['dest'];
540 536
                         $action = 'modify';
@@ -571,8 +567,7 @@  discard block
 block discarded – undo
571 567
             case 'drop':
572 568
                 if ($type=='primary') {
573 569
                     $result.= 'DROP PRIMARY KEY';
574
-                }
575
-                else
570
+                } else
576 571
                 {
577 572
                     $result.= 'DROP INDEX `'.$name.'`';
578 573
                 }
@@ -580,11 +575,9 @@  discard block
 block discarded – undo
580 575
             case 'add':
581 576
                 if ($type=='primary') {
582 577
                     $result.= 'ADD PRIMARY KEY '.$fields;
583
-                }
584
-                elseif ($type=='') {
578
+                } elseif ($type=='') {
585 579
                     $result.= 'ADD INDEX `'.$name.'` '.$fields;
586
-                }
587
-                else
580
+                } else
588 581
                 {
589 582
                     $result .='ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
590 583
                 }
@@ -592,27 +585,23 @@  discard block
 block discarded – undo
592 585
             case 'modify':
593 586
                 if ($type=='primary') {
594 587
                     $result.='DROP PRIMARY KEY, ADD PRIMARY KEY '.$fields;
595
-                }
596
-                elseif ($type=='') {
588
+                } elseif ($type=='') {
597 589
                     $result.='DROP INDEX `'.$name.'`, ADD INDEX `'.$name.'` '.$fields;
598
-                }
599
-                else
590
+                } else
600 591
                 {
601 592
                     $result.='DROP INDEX `'.$name.'`, ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique
602 593
                 }
603 594
                 break;
604 595
 
605 596
             }
606
-        }
607
-        else //fields operations
597
+        } else //fields operations
608 598
         {
609 599
             $sql = rtrim(trim($sql), ',');
610 600
             $result.= strtoupper($action);
611 601
             if ($action=='drop') {
612 602
                 $spacePos = strpos($sql, ' ');
613 603
                 $result.= ' '.substr($sql, 0, $spacePos);
614
-            }
615
-            else
604
+            } else
616 605
             {
617 606
                 $result.= ' '.$sql;
618 607
             }
@@ -637,8 +626,7 @@  discard block
 block discarded – undo
637 626
         $reg = $regPrefix.'("|\')|(/\\*)|(\\*/)|(-- )|(\r\n|\r|\n)|';
638 627
         if ($skipInBrackets) {
639 628
             $reg.='(\(|\))|';
640
-        }
641
-        else 
629
+        } else 
642 630
         {
643 631
             $reg.='()';
644 632
         }
@@ -659,43 +647,47 @@  discard block
 block discarded – undo
659 647
                 continue;//here we could also simplify regexp
660 648
             }
661 649
 
662
-            if (!empty($m[7][0]))// ';' found
650
+            if (!empty($m[7][0])) {
651
+                // ';' found
663 652
             {
664 653
                 if (empty($stack)) {
665 654
                     return $m[7][1];
666
-                }
667
-                else
655
+            }
656
+                } else
668 657
                 {
669 658
                     //var_dump($stack, substr($string, $offset-strlen($m[0][0])));
670 659
                 }
671 660
             }
672
-            if (!empty($m[6][0]))// '(' or ')' found
661
+            if (!empty($m[6][0])) {
662
+                // '(' or ')' found
673 663
             {
674 664
                 if (empty($stack) && $m[6][0]=='(') {
675 665
                     array_push($stack, $m[6][0]);
676
-                }
677
-                elseif($m[6][0]==')' && end($stack)=='(') {
666
+            }
667
+                } elseif($m[6][0]==')' && end($stack)=='(') {
678 668
                     array_pop($stack);
679 669
                 }
680
-            }
681
-            elseif (!empty($m[1][0]))// ' or " found
670
+            } elseif (!empty($m[1][0])) {
671
+                // ' or " found
682 672
             {
683 673
                 if (end($stack)==$m[1][0]) {
684 674
                     array_pop($stack);
685
-                }
686
-                else
675
+            }
676
+                } else
687 677
                 {
688 678
                     array_push($stack, $m[1][0]);
689 679
                 }
690
-            }
691
-            elseif (!empty($m[2][0])) // opening comment / *
680
+            } elseif (!empty($m[2][0])) {
681
+                // opening comment / *
692 682
             {
693 683
                 array_push($stack, $m[2][0]);
694 684
             }
695
-            elseif (!empty($m[4][0])) // opening comment --
685
+            } elseif (!empty($m[4][0])) {
686
+                // opening comment --
696 687
             {
697 688
                 array_push($stack, $m[4][0]);
698 689
             }
690
+            }
699 691
         }
700 692
         return false;
701 693
     }
Please login to merge, or discard this patch.
module/UIComponents/src/UIComponents/View/Helper/Components/Element.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@
 block discarded – undo
33 33
      */
34 34
     public function __invoke($options = array())
35 35
     {
36
-        if ( is_object($options) && method_exists($options, 'toArray') ) {
36
+        if (is_object($options) && method_exists($options, 'toArray')) {
37 37
             $options = $options->toArray();
38
-        } else if ( is_object($options) ) {
39
-            $options = (array)$options;
38
+        } else if (is_object($options)) {
39
+            $options = (array) $options;
40 40
         }
41 41
         
42 42
         if (isset($options['container']) && (null !== $options['container'])) {
Please login to merge, or discard this patch.
UIComponents/src/UIComponents/View/Helper/Components/PluginManager.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected $invokableClasses = [
35 35
 
36
-    	// panels
37
-    	//
36
+        // panels
37
+        //
38 38
         'element'              => 'UIComponents\View\Helper\Components\Element',
39 39
         'block'             => 'UIComponents\View\Helper\Components\Block',
40 40
         //'well'              => 'UIComponents\View\Helper\Components\Well',
@@ -43,33 +43,33 @@  discard block
 block discarded – undo
43 43
         'widget'            => 'UIComponents\View\Helper\Components\Widget',
44 44
         'dashboard'         => 'UIComponents\View\Helper\Components\Dashboard',
45 45
 
46
-    	// page components
47
-    	//
46
+        // page components
47
+        //
48 48
         'nav'               => 'UIComponents\View\Helper\Components\Navbar', // set 'alias to' or combine with 'Navbars' !
49 49
         'topbar'            => 'UIComponents\View\Helper\Components\Navbar', // set 'alias to' or combine with 'Navbars' !
50 50
         'breadcrumbs'       => 'UIComponents\View\Helper\Components\Breadcrumbs',
51 51
         'languagemenu'      => 'UIComponents\View\Helper\Components\Languagemenu',
52
-    	'toolbar'           => 'UIComponents\View\Helper\Components\Toolbar',
52
+        'toolbar'           => 'UIComponents\View\Helper\Components\Toolbar',
53 53
 
54 54
         // controls
55 55
         //
56 56
         'button'            => 'UIComponents\View\Helper\Components\Button', // default, drop-down/up, splitted
57 57
         'buttongroup'       => 'UIComponents\View\Helper\Components\Buttongroup',
58
-    	//'inputgroup'        => 'UIComponents\View\Helper\Components\Inputgroup',
58
+        //'inputgroup'        => 'UIComponents\View\Helper\Components\Inputgroup',
59 59
         //'progressbar'       => 'UIComponents\View\Helper\Components\Progressbar',
60 60
 
61
-    	// forms
62
-    	//
61
+        // forms
62
+        //
63 63
         'formgroup'         => 'UIComponents\View\Helper\Components\Formgroup',
64 64
 
65
-    	// lists/tables
66
-    	//
65
+        // lists/tables
66
+        //
67 67
         //'listgroup'         => 'UIComponents\View\Helper\Components\Listgroup',
68 68
         'table'         	=> 'UIComponents\View\Helper\Components\Listgroup',
69
-    	//'pagination'        => 'UIComponents\View\Helper\Components\Pagination',
69
+        //'pagination'        => 'UIComponents\View\Helper\Components\Pagination',
70 70
 
71
-    	// widgets
72
-    	//
71
+        // widgets
72
+        //
73 73
         //'label'             => 'UIComponents\View\Helper\Components\Label',
74 74
         //'badge'             => 'UIComponents\View\Helper\Components\Badge',
75 75
         //'pageheader'        => 'UIComponents\View\Helper\Components\Pageheader',
Please login to merge, or discard this patch.