Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-17306

Wrong declaration of function input values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.0.0-a1, 3.3.12-RC1
    • 3.3.11
    • Other
    • None

      In:
      The function: get_context() is described as:

      /**
      * Generates a text with approx. the specified length which contains the specified words and their context
      *
      * @param	string	$text	The full text from which context shall be extracted
      * @param	string	$words	An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!)
      * @param	int		$length	The desired length of the resulting text, however the result might be shorter or longer than this value
      *
      * @return	string			Context of the specified words separated by "..."
      */
      function get_context($text, $words, $length = 400)
      

      The $words is described as an array, but marked as an string in the doc-block.

      @param	string	$words	An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!)
      

      Should be changed to:

      @param	array $words	An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!)
      

      Maybe change the function input, too, to:

      function get_context(string $text, array $words, int $length = 400)
      

            Crizzo Crizzo
            Crizzo Crizzo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: