original_string: public static function getRectangularDimensions(array $array)
      {
          $return = -1;
          $allArrays = array_map('is_array', $array);
          // all elements are arrays, iterate through them and call the static function recursively
          if (self::allElementsEqual($allArrays, true)) {
              $elementsPerArray = array();
              foreach ($array as $row) {
                  $noElements = self::getRectangularDimensions($row);
                  if ($noElements == -1) {
                      return $noElements;
                  }
                  $elementsPerArray[] = $noElements;
              }
              if (!self::allElementsEqual($elementsPerArray)) {
                  return -1;
              } else {
                  $return   = reset($elementsPerArray);
                  $return[] = count($elementsPerArray);
              }
          } // none of the elements are arrays, return number of elements of the "bottom" array
          elseif (self::allElementsEqual($allArrays, false)) {
              $return = array(0 => count($array));
          }
  
          return $return;
      }
code: public static function getRectangularDimensions(array $array)
      {
          $return = -1;
          $allArrays = array_map('is_array', $array);
          // all elements are arrays, iterate through them and call the static function recursively
          if (self::allElementsEqual($allArrays, true)) {
              $elementsPerArray = array();
              foreach ($array as $row) {
                  $noElements = self::getRectangularDimensions($row);
                  if ($noElements == -1) {
                      return $noElements;
                  }
                  $elementsPerArray[] = $noElements;
              }
              if (!self::allElementsEqual($elementsPerArray)) {
                  return -1;
              } else {
                  $return   = reset($elementsPerArray);
                  $return[] = count($elementsPerArray);
              }
          } // none of the elements are arrays, return number of elements of the "bottom" array
          elseif (self::allElementsEqual($allArrays, false)) {
              $return = array(0 => count($array));
          }
  
          return $return;
      }
code_tokens: public static function getRectangularDimensions ( array $ array ) { $ return = - 1 ; $ allArrays = array_map ( 'is_array' , $ array ) ; // all elements are arrays, iterate through them and call the static function recursively if ( self :: allElementsEqual ( $ allArrays , true ) ) { $ elementsPerArray = array ( ) ; foreach ( $ array as $ row ) { $ noElements = self :: getRectangularDimensions ( $ row ) ; if ( $ noElements == - 1 ) { return $ noElements ; } $ elementsPerArray [ ] = $ noElements ; } if ( ! self :: allElementsEqual ( $ elementsPerArray ) ) { return - 1 ; } else { $ return = reset ( $ elementsPerArray ) ; $ return [ ] = count ( $ elementsPerArray ) ; } } // none of the elements are arrays, return number of elements of the "bottom" array elseif ( self :: allElementsEqual ( $ allArrays , false ) ) { $ return = array ( 0 => count ( $ array ) ) ; } return $ return ; }
docstring: Checks if an array is rectangular array and returns dimensions or -1 if it's not rectangular
  
  @param array $array
  
  @return int|array
docstring_tokens: Checks if an array is rectangular array and returns dimensions or - 1 if it s not rectangular