original_string: public function eval_cron_field($field, $min, $max) {
          // Cleanse the input.
          $field = trim($field);
  
          // Format for a field is:
          // <fieldlist> := <range>(/<step>)(,<fieldlist>)
          // <step>  := int
          // <range> := <any>|<int>|<min-max>
          // <any>   := *
          // <min-max> := int-int
          // End of format BNF.
  
          // This function is complicated but is covered by unit tests.
          $range = array();
  
          $matches = array();
          preg_match_all('@[0-9]+|\*|,|/|-@', $field, $matches);
  
          $last = 0;
          $inrange = false;
          $instep = false;
  
          foreach ($matches[0] as $match) {
              if ($match == '*') {
                  array_push($range, range($min, $max));
              } else if ($match == '/') {
                  $instep = true;
              } else if ($match == '-') {
                  $inrange = true;
              } else if (is_numeric($match)) {
                  if ($instep) {
                      $i = 0;
                      for ($i = 0; $i < count($range[count($range) - 1]); $i++) {
                          if (($i) % $match != 0) {
                              $range[count($range) - 1][$i] = -1;
                          }
                      }
                      $inrange = false;
                  } else if ($inrange) {
                      if (count($range)) {
                          $range[count($range) - 1] = range($last, $match);
                      }
                      $inrange = false;
                  } else {
                      if ($match >= $min && $match <= $max) {
                          array_push($range, $match);
                      }
                      $last = $match;
                  }
              }
          }
  
          // Flatten the result.
          $result = array();
          foreach ($range as $r) {
              if (is_array($r)) {
                  foreach ($r as $rr) {
                      if ($rr >= $min && $rr <= $max) {
                          $result[$rr] = 1;
                      }
                  }
              } else if (is_numeric($r)) {
                  if ($r >= $min && $r <= $max) {
                      $result[$r] = 1;
                  }
              }
          }
          $result = array_keys($result);
          sort($result, SORT_NUMERIC);
          return $result;
      }
code: public function eval_cron_field($field, $min, $max) {
          // Cleanse the input.
          $field = trim($field);
  
          // Format for a field is:
          // <fieldlist> := <range>(/<step>)(,<fieldlist>)
          // <step>  := int
          // <range> := <any>|<int>|<min-max>
          // <any>   := *
          // <min-max> := int-int
          // End of format BNF.
  
          // This function is complicated but is covered by unit tests.
          $range = array();
  
          $matches = array();
          preg_match_all('@[0-9]+|\*|,|/|-@', $field, $matches);
  
          $last = 0;
          $inrange = false;
          $instep = false;
  
          foreach ($matches[0] as $match) {
              if ($match == '*') {
                  array_push($range, range($min, $max));
              } else if ($match == '/') {
                  $instep = true;
              } else if ($match == '-') {
                  $inrange = true;
              } else if (is_numeric($match)) {
                  if ($instep) {
                      $i = 0;
                      for ($i = 0; $i < count($range[count($range) - 1]); $i++) {
                          if (($i) % $match != 0) {
                              $range[count($range) - 1][$i] = -1;
                          }
                      }
                      $inrange = false;
                  } else if ($inrange) {
                      if (count($range)) {
                          $range[count($range) - 1] = range($last, $match);
                      }
                      $inrange = false;
                  } else {
                      if ($match >= $min && $match <= $max) {
                          array_push($range, $match);
                      }
                      $last = $match;
                  }
              }
          }
  
          // Flatten the result.
          $result = array();
          foreach ($range as $r) {
              if (is_array($r)) {
                  foreach ($r as $rr) {
                      if ($rr >= $min && $rr <= $max) {
                          $result[$rr] = 1;
                      }
                  }
              } else if (is_numeric($r)) {
                  if ($r >= $min && $r <= $max) {
                      $result[$r] = 1;
                  }
              }
          }
          $result = array_keys($result);
          sort($result, SORT_NUMERIC);
          return $result;
      }
code_tokens: public function eval_cron_field ( $ field , $ min , $ max ) { // Cleanse the input. $ field = trim ( $ field ) ; // Format for a field is: // <fieldlist> := <range>(/<step>)(,<fieldlist>) // <step>  := int // <range> := <any>|<int>|<min-max> // <any>   := * // <min-max> := int-int // End of format BNF. // This function is complicated but is covered by unit tests. $ range = array ( ) ; $ matches = array ( ) ; preg_match_all ( '@[0-9]+|\*|,|/|-@' , $ field , $ matches ) ; $ last = 0 ; $ inrange = false ; $ instep = false ; foreach ( $ matches [ 0 ] as $ match ) { if ( $ match == '*' ) { array_push ( $ range , range ( $ min , $ max ) ) ; } else if ( $ match == '/' ) { $ instep = true ; } else if ( $ match == '-' ) { $ inrange = true ; } else if ( is_numeric ( $ match ) ) { if ( $ instep ) { $ i = 0 ; for ( $ i = 0 ; $ i < count ( $ range [ count ( $ range ) - 1 ] ) ; $ i ++ ) { if ( ( $ i ) % $ match != 0 ) { $ range [ count ( $ range ) - 1 ] [ $ i ] = - 1 ; } } $ inrange = false ; } else if ( $ inrange ) { if ( count ( $ range ) ) { $ range [ count ( $ range ) - 1 ] = range ( $ last , $ match ) ; } $ inrange = false ; } else { if ( $ match >= $ min && $ match <= $ max ) { array_push ( $ range , $ match ) ; } $ last = $ match ; } } } // Flatten the result. $ result = array ( ) ; foreach ( $ range as $ r ) { if ( is_array ( $ r ) ) { foreach ( $ r as $ rr ) { if ( $ rr >= $ min && $ rr <= $ max ) { $ result [ $ rr ] = 1 ; } } } else if ( is_numeric ( $ r ) ) { if ( $ r >= $ min && $ r <= $ max ) { $ result [ $ r ] = 1 ; } } } $ result = array_keys ( $ result ) ; sort ( $ result , SORT_NUMERIC ) ; return $ result ; }
docstring: Take a cron field definition and return an array of valid numbers with the range min-max.
  
  @param string $field - The field definition.
  @param int $min - The minimum allowable value.
  @param int $max - The maximum allowable value.
  @return array(int)
docstring_tokens: Take a cron field definition and return an array of valid numbers with the range min - max .