Skip to content

Commit 091e6bd

Browse files
committed
Fix up PHP7 return typehint support.
1 parent de477d4 commit 091e6bd

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

PSR2R/Sniffs/Namespaces/UnusedUseStatementSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
5454
return;
5555
}
5656

57-
$classUsed = $phpcsFile->findNext(T_STRING, ($classNameIndex + 1), null, false, $tokens[$classNameIndex]['content']);
57+
$classUsed = $phpcsFile->findNext([T_STRING, T_RETURN_TYPE], ($classNameIndex + 1), null, false, $tokens[$classNameIndex]['content']);
5858

5959
while ($classUsed !== false) {
6060
$beforeUsage = $phpcsFile->findPrevious(
@@ -74,7 +74,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
7474
return;
7575
}
7676

77-
$classUsed = $phpcsFile->findNext(T_STRING, ($classUsed + 1), null, false, $tokens[$classNameIndex]['content']);
77+
$classUsed = $phpcsFile->findNext([T_STRING, T_RETURN_TYPE], ($classUsed + 1), null, false, $tokens[$classNameIndex]['content']);
7878
}
7979

8080
$warning = 'Unused use statement';

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"bin/sniff"
2929
],
3030
"scripts": {
31-
"docs": "php docs/generate.php"
31+
"docs": "php docs/generate.php",
32+
"cs-check": "vendor/bin/phpcs --standard=PSR2R/ruleset.xml -v --ignore=psr2r-sniffer/vendor/,tests/files/ ./",
33+
"cs-fix": "vendor/bin/phpcbf --standard=PSR2R/ruleset.xml -v --ignore=psr2r-sniffer/vendor/,tests/files/ ./"
3234
}
3335
}

docs/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,17 @@ You can also test specific methods per Test file using `--filter=testNameOfMetho
111111
### Running own sniffs on this project
112112
There is a convenience script to run all sniffs for this repository:
113113
```
114-
sh phpcs.sh
114+
composer cs-check
115115
```
116116
If you want to fix the fixable errors, use
117117
```
118-
sh phpcs.sh -f
118+
composer cs-fix
119119
```
120120
Make sure the root folder name is the same as the GitHub repository name (psr2r-sniffer) to exclude vendor as expected.
121121
Once everything is green you can make a PR with your changes.
122+
123+
### Updating docs
124+
Run
125+
```
126+
composer docs
127+
```

docs/sniffs.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PSR2R Code Sniffer
22

33

4-
The PSR2R/ruleset.xml standard contains 101 sniffs
4+
The PSR2R/ruleset.xml standard contains 102 sniffs
55

66
Generic (13 sniffs)
77
-------------------
@@ -25,7 +25,7 @@ PEAR (3 sniffs)
2525
- PEAR.Functions.ValidDefaultValue
2626
- PEAR.NamingConventions.ValidClassName
2727

28-
PSR2R (64 sniffs)
28+
PSR2R (65 sniffs)
2929
-----------------
3030
- PSR2R.Classes.BraceOnSameLine
3131
- PSR2R.Classes.ClassCreateInstance
@@ -38,6 +38,7 @@ PSR2R (64 sniffs)
3838
- PSR2R.Commenting.DocBlockParamAllowDefaultValue
3939
- PSR2R.Commenting.DocBlockParamArray
4040
- PSR2R.Commenting.DocBlockParamNoOp
41+
- PSR2R.Commenting.DocBlockParamNotJustNull
4142
- PSR2R.Commenting.DocBlockParam
4243
- PSR2R.Commenting.DocBlockPipeSpacing
4344
- PSR2R.Commenting.DocBlockReturnSelf

phpcs.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)