diff vendor/squizlabs/php_codesniffer/src/Files/File.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
line wrap: on
line diff
--- a/vendor/squizlabs/php_codesniffer/src/Files/File.php	Thu Feb 28 13:11:55 2019 +0000
+++ b/vendor/squizlabs/php_codesniffer/src/Files/File.php	Thu May 09 15:34:47 2019 +0100
@@ -27,7 +27,7 @@
     public $path = '';
 
     /**
-     * The absolute path to the file associated with this object.
+     * The content of the file.
      *
      * @var string
      */
@@ -392,26 +392,13 @@
                 } else if (substr($commentTextLower, 0, 9) === 'phpcs:set'
                     || substr($commentTextLower, 0, 10) === '@phpcs:set'
                 ) {
-                    // If the @phpcs: syntax is being used, strip the @ to make
-                    // comparisons easier.
-                    if ($commentText[0] === '@') {
-                        $commentText = substr($commentText, 1);
-                    }
-
-                    // Need to maintain case here, to get the correct sniff code.
-                    $parts = explode(' ', substr($commentText, 10));
-                    if (count($parts) >= 2) {
-                        $sniffParts = explode('.', $parts[0]);
-                        if (count($sniffParts) >= 3) {
-                            // If the sniff code is not known to us, it has not been registered in this run.
-                            // But don't throw an error as it could be there for a different standard to use.
-                            if (isset($this->ruleset->sniffCodes[$parts[0]]) === true) {
-                                $listenerCode  = array_shift($parts);
-                                $propertyCode  = array_shift($parts);
-                                $propertyValue = rtrim(implode(' ', $parts), " */\r\n");
-                                $listenerClass = $this->ruleset->sniffCodes[$listenerCode];
-                                $this->ruleset->setSniffProperty($listenerClass, $propertyCode, $propertyValue);
-                            }
+                    if (isset($token['sniffCode']) === true) {
+                        $listenerCode = $token['sniffCode'];
+                        if (isset($this->ruleset->sniffCodes[$listenerCode]) === true) {
+                            $propertyCode  = $token['sniffProperty'];
+                            $propertyValue = $token['sniffPropertyValue'];
+                            $listenerClass = $this->ruleset->sniffCodes[$listenerCode];
+                            $this->ruleset->setSniffProperty($listenerClass, $propertyCode, $propertyValue);
                         }
                     }
                 }//end if
@@ -908,9 +895,9 @@
         // due to the use of the --sniffs command line argument.
         if ($includeAll === false
             && ((empty($this->configCache['sniffs']) === false
-            && in_array(strtolower($listenerCode), $this->configCache['sniffs']) === false)
+            && in_array(strtolower($listenerCode), $this->configCache['sniffs'], true) === false)
             || (empty($this->configCache['exclude']) === false
-            && in_array(strtolower($listenerCode), $this->configCache['exclude']) === true))
+            && in_array(strtolower($listenerCode), $this->configCache['exclude'], true) === true))
         ) {
             return false;
         }
@@ -1134,18 +1121,6 @@
 
 
     /**
-     * Returns the number of successes recorded.
-     *
-     * @return int
-     */
-    public function getSuccessCount()
-    {
-        return $this->successCount;
-
-    }//end getSuccessCount()
-
-
-    /**
      * Returns the number of fixable errors/warnings raised.
      *
      * @return int
@@ -1991,20 +1966,20 @@
      *
      * Returns false if no token can be found.
      *
-     * @param int|array $types   The type(s) of tokens to search for.
-     * @param int       $start   The position to start searching from in the
-     *                           token stack.
-     * @param int       $end     The end position to fail if no token is found.
-     *                           if not specified or null, end will default to
-     *                           the start of the token stack.
-     * @param bool      $exclude If true, find the previous token that is NOT of
-     *                           the types specified in $types.
-     * @param string    $value   The value that the token(s) must be equal to.
-     *                           If value is omitted, tokens with any value will
-     *                           be returned.
-     * @param bool      $local   If true, tokens outside the current statement
-     *                           will not be checked. IE. checking will stop
-     *                           at the previous semi-colon found.
+     * @param int|string|array $types   The type(s) of tokens to search for.
+     * @param int              $start   The position to start searching from in the
+     *                                  token stack.
+     * @param int              $end     The end position to fail if no token is found.
+     *                                  if not specified or null, end will default to
+     *                                  the start of the token stack.
+     * @param bool             $exclude If true, find the previous token that is NOT of
+     *                                  the types specified in $types.
+     * @param string           $value   The value that the token(s) must be equal to.
+     *                                  If value is omitted, tokens with any value will
+     *                                  be returned.
+     * @param bool             $local   If true, tokens outside the current statement
+     *                                  will not be checked. IE. checking will stop
+     *                                  at the previous semi-colon found.
      *
      * @return int|bool
      * @see    findNext()
@@ -2072,20 +2047,20 @@
      *
      * Returns false if no token can be found.
      *
-     * @param int|array $types   The type(s) of tokens to search for.
-     * @param int       $start   The position to start searching from in the
-     *                           token stack.
-     * @param int       $end     The end position to fail if no token is found.
-     *                           if not specified or null, end will default to
-     *                           the end of the token stack.
-     * @param bool      $exclude If true, find the next token that is NOT of
-     *                           a type specified in $types.
-     * @param string    $value   The value that the token(s) must be equal to.
-     *                           If value is omitted, tokens with any value will
-     *                           be returned.
-     * @param bool      $local   If true, tokens outside the current statement
-     *                           will not be checked. i.e., checking will stop
-     *                           at the next semi-colon found.
+     * @param int|string|array $types   The type(s) of tokens to search for.
+     * @param int              $start   The position to start searching from in the
+     *                                  token stack.
+     * @param int              $end     The end position to fail if no token is found.
+     *                                  if not specified or null, end will default to
+     *                                  the end of the token stack.
+     * @param bool             $exclude If true, find the next token that is NOT of
+     *                                  a type specified in $types.
+     * @param string           $value   The value that the token(s) must be equal to.
+     *                                  If value is omitted, tokens with any value will
+     *                                  be returned.
+     * @param bool             $local   If true, tokens outside the current statement
+     *                                  will not be checked. i.e., checking will stop
+     *                                  at the next semi-colon found.
      *
      * @return int|bool
      * @see    findPrevious()
@@ -2154,9 +2129,7 @@
         if ($ignore !== null) {
             $ignore = (array) $ignore;
             foreach ($ignore as $code) {
-                if (isset($endTokens[$code]) === true) {
-                    unset($endTokens[$code]);
-                }
+                unset($endTokens[$code]);
             }
         }
 
@@ -2222,9 +2195,7 @@
         if ($ignore !== null) {
             $ignore = (array) $ignore;
             foreach ($ignore as $code) {
-                if (isset($endTokens[$code]) === true) {
-                    unset($endTokens[$code]);
-                }
+                unset($endTokens[$code]);
             }
         }
 
@@ -2281,15 +2252,15 @@
      *
      * Returns false if no token can be found.
      *
-     * @param int|array $types   The type(s) of tokens to search for.
-     * @param int       $start   The position to start searching from in the
-     *                           token stack. The first token matching on
-     *                           this line before this token will be returned.
-     * @param bool      $exclude If true, find the token that is NOT of
-     *                           the types specified in $types.
-     * @param string    $value   The value that the token must be equal to.
-     *                           If value is omitted, tokens with any value will
-     *                           be returned.
+     * @param int|string|array $types   The type(s) of tokens to search for.
+     * @param int              $start   The position to start searching from in the
+     *                                  token stack. The first token matching on
+     *                                  this line before this token will be returned.
+     * @param bool             $exclude If true, find the token that is NOT of
+     *                                  the types specified in $types.
+     * @param string           $value   The value that the token must be equal to.
+     *                                  If value is omitted, tokens with any value will
+     *                                  be returned.
      *
      * @return int | bool
      */
@@ -2338,8 +2309,8 @@
     /**
      * Determine if the passed token has a condition of one of the passed types.
      *
-     * @param int       $stackPtr The position of the token we are checking.
-     * @param int|array $types    The type(s) of tokens to search for.
+     * @param int              $stackPtr The position of the token we are checking.
+     * @param int|string|array $types    The type(s) of tokens to search for.
      *
      * @return boolean
      */
@@ -2359,7 +2330,7 @@
         $conditions = $this->tokens[$stackPtr]['conditions'];
 
         foreach ($types as $type) {
-            if (in_array($type, $conditions) === true) {
+            if (in_array($type, $conditions, true) === true) {
                 // We found a token with the required type.
                 return true;
             }
@@ -2375,8 +2346,8 @@
      *
      * Returns FALSE if the token does not have the condition.
      *
-     * @param int $stackPtr The position of the token we are checking.
-     * @param int $type     The type of token to search for.
+     * @param int        $stackPtr The position of the token we are checking.
+     * @param int|string $type     The type of token to search for.
      *
      * @return int
      */