Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ClassFilesSniff.php

function ClassFilesSniff::getPtr

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\Files\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 ClassFilesSniff::getPtr()
ClassFilesSniff::process in vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php
Processes this test, when one of its tokens is encountered.
RequiredSniff::process in vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php
Processes this test, when one of its tokens is encountered.

File

vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php, line 103

Class

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

Namespace

Drupal\Sniffs\InfoFiles

Code

public static function getPtr($key, $value, 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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal