Skip to content

Commit ccc228f

Browse files
authored
Merge pull request #31 from humanmade/update-phpcs
Update phpcs to v3
2 parents f608de2 + ec1bf42 commit ccc228f

File tree

9 files changed

+44
-44
lines changed

9 files changed

+44
-44
lines changed

HM/Sniffs/Classes/OnlyClassInFileSniff.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
namespace HM\Sniffs\Classes;
44

5-
use PHP_CodeSniffer_File;
6-
use PHP_CodeSniffer_Sniff;
7-
use PHP_CodeSniffer_Tokens;
5+
use PHP_CodeSniffer\Files\File;
6+
use PHP_CodeSniffer\Sniffs\Sniff;
87

98
/**
109
* Sniff to check classes are by themselves.
1110
*/
12-
class OnlyClassInFileSniff implements PHP_CodeSniffer_Sniff {
11+
class OnlyClassInFileSniff implements Sniff {
1312
/**
1413
* Returns an array of tokens this test wants to listen for.
1514
*
@@ -28,7 +27,7 @@ public function register() {
2827
*
2928
* @return void
3029
*/
31-
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
30+
public function process( File $phpcsFile, $stackPtr ) {
3231
$error = 'Files should only contain a single class, and no other declarations. First class was defined on line %s, and a %s was found on line %s.';
3332

3433
$tokens = $phpcsFile->getTokens();

HM/Sniffs/Debug/ESLintSniff.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace HM\Sniffs\Debug;
44

5-
use PHP_CodeSniffer;
6-
use PHP_CodeSniffer_File;
7-
use PHP_CodeSniffer_Sniff;
5+
use PHP_CodeSniffer\Config;
6+
use PHP_CodeSniffer\Files\File;
7+
use PHP_CodeSniffer\Sniffs\Sniff;
88

99
/**
1010
* Run ESLint on the file.
1111
*/
12-
class ESLintSniff implements PHP_CodeSniffer_Sniff {
12+
class ESLintSniff implements Sniff {
1313
/**
1414
* Path to default configuration.
1515
*/
@@ -41,16 +41,16 @@ public function register() {
4141
/**
4242
* Processes the tokens that this sniff is interested in.
4343
*
44-
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
45-
* @param int $stackPtr The position in the stack where
44+
* @param File $phpcsFile The file where the token was found.
45+
* @param int $stackPtr The position in the stack where
4646
* the token was found.
4747
*
4848
* @return void
4949
* @throws PHP_CodeSniffer_Exception If jslint.js could not be run
5050
*/
51-
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
51+
public function process( File $phpcsFile, $stackPtr ) {
5252
$filename = $phpcsFile->getFilename();
53-
$eslint_path = PHP_CodeSniffer::getConfigData( 'eslint_path' );
53+
$eslint_path = Config::getConfigData( 'eslint_path' );
5454
if ( $eslint_path === null ) {
5555
return;
5656
}

HM/Sniffs/Files/ClassFileNameSniff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
namespace HM\Sniffs\Files;
33

4-
use PHP_CodeSniffer_File;
5-
use PHP_CodeSniffer_Sniff;
4+
use PHP_CodeSniffer\Files\File;
5+
use PHP_CodeSniffer\Sniffs\Sniff;
66

77
/**
88
* Filenames with classes must start with class- and be the class name.
99
*/
10-
class ClassFileNameSniff implements PHP_CodeSniffer_Sniff {
10+
class ClassFileNameSniff implements Sniff {
1111
/**
1212
* Returns an array of tokens this test wants to listen for.
1313
*
@@ -20,13 +20,13 @@ public function register() {
2020
/**
2121
* Processes this test, when one of its tokens is encountered.
2222
*
23-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
24-
* @param int $stackPtr The position of the current token in the
25-
* stack passed in $tokens.
23+
* @param File $phpcsFile The file being scanned.
24+
* @param int $stackPtr The position of the current token in the
25+
* stack passed in $tokens.
2626
*
2727
* @return int
2828
*/
29-
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
29+
public function process( File $phpcsFile, $stackPtr ) {
3030
$tokens = $phpcsFile->getTokens();
3131
$namespace_ptr = $phpcsFile->findNext(T_NAMESPACE, 0);
3232
if ( ! $namespace_ptr ) {

HM/Sniffs/Files/FunctionFileNameSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22
namespace HM\Sniffs\Files;
33

4-
use PHP_CodeSniffer_File;
5-
use PHP_CodeSniffer_Sniff;
4+
use PHP_CodeSniffer\Files\File;
5+
use PHP_CodeSniffer\Sniffs\Sniff;
66

77
/**
88
* Sniff to check for namespaced functions are in `namespace.php`.
99
*/
10-
class FunctionFileNameSniff implements PHP_CodeSniffer_Sniff {
10+
class FunctionFileNameSniff implements Sniff {
1111
public function register() {
1212
return array( T_FUNCTION );
1313
}
1414

15-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
15+
public function process( File $phpcsFile, $stackPtr ) {
1616
$tokens = $phpcsFile->getTokens();
1717
if ( $tokens[ $stackPtr ]['level'] !== 0 ) {
1818
// Ignore methods.

HM/Sniffs/Files/NamespaceDirectoryNameSniff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
namespace HM\Sniffs\Files;
33

4-
use PHP_CodeSniffer_File;
5-
use PHP_CodeSniffer_Sniff;
4+
use PHP_CodeSniffer\Files\File;
5+
use PHP_CodeSniffer\Sniffs\Sniff;
66

77
/**
88
* Namespaced things must be in directories matching the namespace.
99
*/
10-
class NamespaceDirectoryNameSniff implements PHP_CodeSniffer_Sniff {
10+
class NamespaceDirectoryNameSniff implements Sniff {
1111
/**
1212
* Returns an array of tokens this test wants to listen for.
1313
*
@@ -20,13 +20,13 @@ public function register() {
2020
/**
2121
* Processes this test, when one of its tokens is encountered.
2222
*
23-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
24-
* @param int $stackPtr The position of the current token in the
25-
* stack passed in $tokens.
23+
* @param File $phpcsFile The file being scanned.
24+
* @param int $stackPtr The position of the current token in the
25+
* stack passed in $tokens.
2626
*
2727
* @return int
2828
*/
29-
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
29+
public function process( File $phpcsFile, $stackPtr ) {
3030
$tokens = $phpcsFile->getTokens();
3131
$namespace = '';
3232

HM/Sniffs/Functions/NamespacedFunctionsSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22
namespace HM\Sniffs\Functions;
33

4-
use PHP_CodeSniffer_File;
5-
use PHP_CodeSniffer_Sniff;
4+
use PHP_CodeSniffer\Files\File;
5+
use PHP_CodeSniffer\Sniffs\Sniff;
66

77
/**
88
* Sniff to check for namespaces for functions.
99
*/
10-
class NamespacedFunctionsSniff implements PHP_CodeSniffer_Sniff {
10+
class NamespacedFunctionsSniff implements Sniff {
1111
public function register() {
1212
return array( T_FUNCTION );
1313
}
1414

15-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
15+
public function process( File $phpcsFile, $stackPtr ) {
1616
$tokens = $phpcsFile->getTokens();
1717
if (isset($tokens[$stackPtr]['scope_closer']) === false) {
1818
return;

HM/Sniffs/Layout/OrderSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22
namespace HM\Sniffs\Layout;
33

4-
use PHP_CodeSniffer_File;
5-
use PHP_CodeSniffer_Sniff;
4+
use PHP_CodeSniffer\Files\File;
5+
use PHP_CodeSniffer\Sniffs\Sniff;
66

77
/**
88
* Sniff to check order of declarations (namespace, use, const, code).
99
*/
10-
class OrderSniff implements PHP_CodeSniffer_Sniff {
10+
class OrderSniff implements Sniff {
1111
public function register() {
1212
return array( T_OPEN_TAG );
1313
}
1414

15-
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
15+
public function process( File $phpcsFile, $stackPtr ) {
1616
$tokens = $phpcsFile->getTokens();
1717

1818
// Things we can look for:

HM/Sniffs/Namespaces/NoLeadingSlashOnUseSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22
namespace HM\Sniffs\Namespaces;
33

4-
use PHP_CodeSniffer_File;
5-
use PHP_CodeSniffer_Sniff;
4+
use PHP_CodeSniffer\Files\File;
5+
use PHP_CodeSniffer\Sniffs\Sniff;
66

77
/**
88
* Sniff to check `use` class isn't prefixed with `\`
99
*/
10-
class NoLeadingSlashOnUseSniff implements PHP_CodeSniffer_Sniff {
10+
class NoLeadingSlashOnUseSniff implements Sniff {
1111
public function register() {
1212
return array( T_USE );
1313
}
1414

15-
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
15+
public function process( File $phpcsFile, $stackPtr ) {
1616
$tokens = $phpcsFile->getTokens();
1717
$look_for = [ T_STRING, T_NS_SEPARATOR ];
1818
$next = $phpcsFile->findNext( $look_for, $stackPtr );

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"license": "GPL-2.0",
66
"require": {
77
"wp-coding-standards/wpcs": "^0.13.1",
8-
"fig-r/psr2r-sniffer": "^0.4.1"
8+
"fig-r/psr2r-sniffer": "dev-master",
9+
"squizlabs/php_codesniffer": "^3.1"
910
}
1011
}

0 commit comments

Comments
 (0)