@@ -145,9 +145,9 @@ public function delTypeAlias($alias)
145145 */
146146 public function changeIfIsAlias ($ type_src )
147147 {
148- static $ aliases_arr = false ;
148+ static $ aliases_arr = [] ;
149149 $ t_lower = \strtolower ($ type_src );
150- if (! $ aliases_arr || empty ($ type_src )) {
150+ if (empty ( $ aliases_arr) || empty ($ type_src )) {
151151 $ aliases_arr = $ this ->types_aliases ;
152152 foreach ($ this ->types_fix_size as $ canon => $ v ) {
153153 $ aliases_arr [strtolower ($ canon )] = $ canon ;
@@ -519,13 +519,13 @@ public function getTableRowSize($table_or_fields_arr)
519519 $ fields_arr = $ table_or_fields_arr ;
520520 $ table_name = null ;
521521 }
522- $ dynamic_fields = 0 ;
523- $ fixed_bytes = $ comment = $ this ->countRowFixedSize ($ fields_arr , $ dynamic_fields );
524- if (!\is_numeric ($ fixed_bytes )) {
522+ $ fixed_bytes = $ this ->countRowFixedSize ($ fields_arr );
523+ if (!\is_array ($ fixed_bytes )) {
525524 return $ fixed_bytes ;
526525 }
526+ \extract ($ fixed_bytes ); // fixed_bytes, dynamic_fields
527527 $ fixed_fields = \count ($ fields_arr ) - $ dynamic_fields ;
528- $ comment . = " bytes in $ fixed_fields FIXED FIELDS, $ dynamic_fields DYNAMIC FIELDS " ;
528+ $ comment = "$ fixed_bytes bytes in $ fixed_fields FIXED FIELDS, $ dynamic_fields DYNAMIC FIELDS " ;
529529 return \compact ('table_name ' , 'fixed_bytes ' , 'fixed_fields ' , 'dynamic_fields ' , 'comment ' );
530530 }
531531
@@ -536,9 +536,9 @@ public function getTableRowSize($table_or_fields_arr)
536536 *
537537 * @param array $fields_arr Array [field_name]=>[field_type]
538538 * @param integer $dynamic_fields (by reference)
539- * @return integer |string Integer of fixed_bytes or string with error description
539+ * @return array |string Array of [ fixed_bytes,dynamic_fields] or string with error description
540540 */
541- public function countRowFixedSize ($ fields_arr, & $ dynamic_fields = 0 )
541+ public function countRowFixedSize ($ fields_arr )
542542 {
543543 if (!\is_array ($ fields_arr ) || !\count ($ fields_arr )) {
544544 return "Need array " ;
@@ -549,15 +549,15 @@ public function countRowFixedSize($fields_arr, &$dynamic_fields = 0)
549549 } catch (\Exception $ e ) {
550550 return $ e ->getMessage ();
551551 }
552- $ sum = 0 ;
552+ $ fixed_bytes = $ dynamic_fields = 0 ;
553553 foreach (\array_column ($ parsed_arr , 'bytes ' ) as $ bytes ) {
554554 if ($ bytes ) {
555- $ sum += $ bytes ;
555+ $ fixed_bytes += $ bytes ;
556556 } else {
557557 $ dynamic_fields ++;
558558 }
559559 }
560- return $ sum ;
560+ return compact ( ' fixed_bytes ' , ' dynamic_fields ' ) ;
561561 }
562562
563563 /**
0 commit comments