Skip to content

Commit 1034359

Browse files
authored
Merge pull request #366 from PHPCSStandards/feature/universal-disallowuse-only-catch-what-should-be-caught
Universal/DisallowUse*: only catch what should be caught
2 parents 42289c4 + 1a39d36 commit 1034359

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Universal/Sniffs/UseStatements/DisallowUseClassSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
namespace PHPCSExtra\Universal\Sniffs\UseStatements;
1212

13-
use PHP_CodeSniffer\Exceptions\RuntimeException;
1413
use PHP_CodeSniffer\Files\File;
1514
use PHP_CodeSniffer\Sniffs\Sniff;
1615
use PHP_CodeSniffer\Util\Tokens;
16+
use PHPCSUtils\Exceptions\ValueError;
1717
use PHPCSUtils\Utils\Namespaces;
1818
use PHPCSUtils\Utils\UseStatements;
1919

@@ -115,7 +115,7 @@ public function process(File $phpcsFile, $stackPtr)
115115
// Ok, so this is a T_USE token.
116116
try {
117117
$statements = UseStatements::splitImportUseStatement($phpcsFile, $stackPtr);
118-
} catch (RuntimeException $e) {
118+
} catch (ValueError $e) {
119119
// Not an import use statement. Bow out.
120120
return;
121121
}

Universal/Sniffs/UseStatements/DisallowUseConstSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
namespace PHPCSExtra\Universal\Sniffs\UseStatements;
1212

13-
use PHP_CodeSniffer\Exceptions\RuntimeException;
1413
use PHP_CodeSniffer\Files\File;
1514
use PHP_CodeSniffer\Sniffs\Sniff;
1615
use PHP_CodeSniffer\Util\Tokens;
16+
use PHPCSUtils\Exceptions\ValueError;
1717
use PHPCSUtils\Utils\Namespaces;
1818
use PHPCSUtils\Utils\UseStatements;
1919

@@ -115,7 +115,7 @@ public function process(File $phpcsFile, $stackPtr)
115115
// Ok, so this is a T_USE token.
116116
try {
117117
$statements = UseStatements::splitImportUseStatement($phpcsFile, $stackPtr);
118-
} catch (RuntimeException $e) {
118+
} catch (ValueError $e) {
119119
// Not an import use statement. Bow out.
120120
return;
121121
}

Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
namespace PHPCSExtra\Universal\Sniffs\UseStatements;
1212

13-
use PHP_CodeSniffer\Exceptions\RuntimeException;
1413
use PHP_CodeSniffer\Files\File;
1514
use PHP_CodeSniffer\Sniffs\Sniff;
1615
use PHP_CodeSniffer\Util\Tokens;
16+
use PHPCSUtils\Exceptions\ValueError;
1717
use PHPCSUtils\Utils\Namespaces;
1818
use PHPCSUtils\Utils\UseStatements;
1919

@@ -115,7 +115,7 @@ public function process(File $phpcsFile, $stackPtr)
115115
// Ok, so this is a T_USE token.
116116
try {
117117
$statements = UseStatements::splitImportUseStatement($phpcsFile, $stackPtr);
118-
} catch (RuntimeException $e) {
118+
} catch (ValueError $e) {
119119
// Not an import use statement. Bow out.
120120
return;
121121
}

0 commit comments

Comments
 (0)