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

Breadcrumb

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

function StrictSchemaDisabledSniff::isTestClass

Determine if this class is a test class.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:

int $stackPtr The position of the current token: in the stack passed in $tokens.

Return value

bool Returns TRUE if the current class is a test class.

1 call to StrictSchemaDisabledSniff::isTestClass()
StrictSchemaDisabledSniff::processMemberVar in vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/Objects/StrictSchemaDisabledSniff.php
Processes this test, when one of its tokens is encountered.

File

vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/Objects/StrictSchemaDisabledSniff.php, line 79

Class

StrictSchemaDisabledSniff
Checks that $strictConfigSchema is not set to FALSE in test classes.

Namespace

DrupalPractice\Sniffs\Objects

Code

protected function isTestClass(File $phpcsFile, $stackPtr) {
    // Only applies to test classes, which have Test in the name.
    $tokens = $phpcsFile->getTokens();
    $classPtr = key($tokens[$stackPtr]['conditions']);
    $name = $phpcsFile->findNext([
        T_STRING,
    ], $classPtr);
    return strpos($tokens[$name]['content'], 'Test') !== false;
}
RSS feed
Powered by Drupal