comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 /** 2 /**
3 * Drupal_Sniffs_NamingConventions_ValidClassNameSniff. 3 * \Drupal\Sniffs\NamingConventions\ValidClassNameSniff.
4 * 4 *
5 * @category PHP 5 * @category PHP
6 * @package PHP_CodeSniffer 6 * @package PHP_CodeSniffer
7 * @author Greg Sherwood <gsherwood@squiz.net> 7 * @author Greg Sherwood <gsherwood@squiz.net>
8 * @author Marc McIntyre <mmcintyre@squiz.net> 8 * @author Marc McIntyre <mmcintyre@squiz.net>
9 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) 9 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
10 * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence 10 * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
11 * @link http://pear.php.net/package/PHP_CodeSniffer 11 * @link http://pear.php.net/package/PHP_CodeSniffer
12 */ 12 */
13 13
14 namespace Drupal\Sniffs\NamingConventions;
15
16 use PHP_CodeSniffer\Files\File;
17 use PHP_CodeSniffer\Sniffs\Sniff;
18
14 /** 19 /**
15 * Drupal_Sniffs_NamingConventions_ValidClassNameSniff. 20 * \Drupal\Sniffs\NamingConventions\ValidClassNameSniff.
16 * 21 *
17 * Ensures class and interface names start with a capital letter 22 * Ensures class and interface names start with a capital letter
18 * and do not use _ separators. 23 * and do not use _ separators.
19 * 24 *
20 * @category PHP 25 * @category PHP
24 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) 29 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
25 * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence 30 * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
26 * @version Release: 1.2.0RC3 31 * @version Release: 1.2.0RC3
27 * @link http://pear.php.net/package/PHP_CodeSniffer 32 * @link http://pear.php.net/package/PHP_CodeSniffer
28 */ 33 */
29 class Drupal_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSniffer_Sniff 34 class ValidClassNameSniff implements Sniff
30 { 35 {
31 36
32 37
33 /** 38 /**
34 * Returns an array of tokens this test wants to listen for. 39 * Returns an array of tokens this test wants to listen for.
46 51
47 52
48 /** 53 /**
49 * Processes this test, when one of its tokens is encountered. 54 * Processes this test, when one of its tokens is encountered.
50 * 55 *
51 * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. 56 * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being processed.
52 * @param int $stackPtr The position of the current token 57 * @param int $stackPtr The position of the current token
53 * in the stack passed in $tokens. 58 * in the stack passed in $tokens.
54 * 59 *
55 * @return void 60 * @return void
56 */ 61 */
57 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) 62 public function process(File $phpcsFile, $stackPtr)
58 { 63 {
59 $tokens = $phpcsFile->getTokens(); 64 $tokens = $phpcsFile->getTokens();
60 65
61 $className = $phpcsFile->findNext(T_STRING, $stackPtr); 66 $className = $phpcsFile->findNext(T_STRING, $stackPtr);
62 $name = trim($tokens[$className]['content']); 67 $name = trim($tokens[$className]['content']);