You are here

public static function Drupal_Sniffs_InfoFiles_ClassFilesSniff::getPtr in Coder 7.2

Helper function that returns the position of the key in the info file.

Parameters

string $key Key name to search for.:

string $value Corresponding value to search for.:

PHP_CodeSniffer_File $infoFile Info file to search in.:

Return value

int|false Returns the stack position if the file name is found, false otherwise.

2 calls to Drupal_Sniffs_InfoFiles_ClassFilesSniff::getPtr()
Drupal_Sniffs_InfoFiles_ClassFilesSniff::process in coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php
Processes this test, when one of its tokens is encountered.
Drupal_Sniffs_InfoFiles_RequiredSniff::process in coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php
Processes this test, when one of its tokens is encountered.

File

coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php, line 99

Class

Drupal_Sniffs_InfoFiles_ClassFilesSniff
Checks files[] entries in info files. Only files containing classes/interfaces should be listed.

Code

public static function getPtr($key, $value, PHP_CodeSniffer_File $infoFile) {
  foreach ($infoFile
    ->getTokens() as $ptr => $tokenInfo) {
    if (preg_match('@^[\\s]*' . preg_quote($key) . '[\\s]*=[\\s]*["\']?' . preg_quote($value) . '["\']?@', $tokenInfo['content']) === 1) {
      return $ptr;
    }
  }
  return false;
}