original_string: public static function allElementsEqual(array $haystack, $needle = null)
      {
          $return = true;
          // if both arguments have been passed, use value argument (regardless of whether it is null or not
          if (func_num_args() == 2) {
              $compareAgainst = $needle;
          } // only one argument has been passed, so compare elements only to each other
          else {
              $compareAgainst = reset($haystack);
          }
          foreach ($haystack as $element) {
              if ($compareAgainst != $element) {
                  $return = false;
                  break;
              }
          }
  
          return $return;
      }
code: public static function allElementsEqual(array $haystack, $needle = null)
      {
          $return = true;
          // if both arguments have been passed, use value argument (regardless of whether it is null or not
          if (func_num_args() == 2) {
              $compareAgainst = $needle;
          } // only one argument has been passed, so compare elements only to each other
          else {
              $compareAgainst = reset($haystack);
          }
          foreach ($haystack as $element) {
              if ($compareAgainst != $element) {
                  $return = false;
                  break;
              }
          }
  
          return $return;
      }
code_tokens: public static function allElementsEqual ( array $ haystack , $ needle = null ) { $ return = true ; // if both arguments have been passed, use value argument (regardless of whether it is null or not if ( func_num_args ( ) == 2 ) { $ compareAgainst = $ needle ; } // only one argument has been passed, so compare elements only to each other else { $ compareAgainst = reset ( $ haystack ) ; } foreach ( $ haystack as $ element ) { if ( $ compareAgainst != $ element ) { $ return = false ; break ; } } return $ return ; }
docstring: Checks if all elements of the array have same value
  
  @param array $haystack
  @param mixed $needle
  
  @return boolean
docstring_tokens: Checks if all elements of the array have same value