1
1
<?php
2
2
3
- class Chadicus_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commenting_FunctionCommentSniff
3
+ namespace Chadicus \Sniffs \Commenting ;
4
+
5
+ use PHP_CodeSniffer \Config ;
6
+ use PHP_CodeSniffer \Files \File ;
7
+ use PHP_CodeSniffer \Standards \PEAR \Sniffs \Commenting \FunctionCommentSniff as PEARFunctionCommentSniff ;
8
+ use PHP_CodeSniffer \Util \Common ;
9
+
10
+ class FunctionCommentSniff extends PEARFunctionCommentSniff
4
11
{
5
12
/**
6
13
* The current PHP version.
@@ -19,12 +26,12 @@ class Chadicus_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commen
19
26
/**
20
27
* Ensures only public methods are processed.
21
28
*
22
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
23
- * @param int $stackPtr The position of the current token in the stack passed in $tokens.
29
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
30
+ * @param int $stackPtr The position of the current token in the stack passed in $tokens.
24
31
*
25
32
* @return void
26
33
*/
27
- public function process (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr )
34
+ public function process (File $ phpcsFile , $ stackPtr )
28
35
{
29
36
$ methodProperties = $ phpcsFile ->getMethodProperties ($ stackPtr );
30
37
if ($ methodProperties ['scope ' ] !== 'public ' ) {
@@ -37,14 +44,14 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
37
44
/**
38
45
* Process the return comment of this function comment.
39
46
*
40
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
41
- * @param int $stackPtr The position of the current token
42
- * in the stack passed in $tokens.
43
- * @param int $commentStart The position in the stack where the comment started.
47
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
48
+ * @param int $stackPtr The position of the current token
49
+ * in the stack passed in $tokens.
50
+ * @param int $commentStart The position in the stack where the comment started.
44
51
*
45
52
* @return void
46
53
*/
47
- protected function processReturn (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr , $ commentStart )
54
+ protected function processReturn (File $ phpcsFile , $ stackPtr , $ commentStart )
48
55
{
49
56
$ tokens = $ phpcsFile ->getTokens ();
50
57
@@ -187,14 +194,14 @@ private function isReturnVoid($phpcsFile, $tokens, $stackPtr) : bool
187
194
/**
188
195
* Process any throw tags that this function comment has.
189
196
*
190
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
191
- * @param int $stackPtr The position of the current token
192
- * in the stack passed in $tokens.
193
- * @param int $commentStart The position in the stack where the comment started.
197
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
198
+ * @param int $stackPtr The position of the current token
199
+ * in the stack passed in $tokens.
200
+ * @param int $commentStart The position in the stack where the comment started.
194
201
*
195
202
* @return void
196
203
*/
197
- protected function processThrows (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr , $ commentStart )
204
+ protected function processThrows (File $ phpcsFile , $ stackPtr , $ commentStart )
198
205
{
199
206
$ tokens = $ phpcsFile ->getTokens ();
200
207
@@ -242,17 +249,17 @@ protected function processThrows(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
242
249
/**
243
250
* Process the function parameter comments.
244
251
*
245
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
246
- * @param int $stackPtr The position of the current token
247
- * in the stack passed in $tokens.
248
- * @param int $commentStart The position in the stack where the comment started.
252
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
253
+ * @param int $stackPtr The position of the current token
254
+ * in the stack passed in $tokens.
255
+ * @param int $commentStart The position in the stack where the comment started.
249
256
*
250
257
* @return void
251
258
*/
252
- protected function processParams (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr , $ commentStart )
259
+ protected function processParams (File $ phpcsFile , $ stackPtr , $ commentStart )
253
260
{
254
261
if ($ this ->_phpVersion === null ) {
255
- $ this ->_phpVersion = PHP_CodeSniffer ::getConfigData ('php_version ' );
262
+ $ this ->_phpVersion = Config ::getConfigData ('php_version ' );
256
263
if ($ this ->_phpVersion === null ) {
257
264
$ this ->_phpVersion = PHP_VERSION_ID ;
258
265
}
@@ -388,7 +395,7 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
388
395
$ suggestedTypeHint = 'callable ' ;
389
396
} else if (strpos ($ suggestedName , 'callback ' ) !== false ) {
390
397
$ suggestedTypeHint = 'callable ' ;
391
- } else if (in_array ($ suggestedName , PHP_CodeSniffer ::$ allowedTypes ) === false ) {
398
+ } else if (in_array ($ suggestedName , Common ::$ allowedTypes ) === false ) {
392
399
$ suggestedTypeHint = $ suggestedName ;
393
400
}
394
401
@@ -548,14 +555,14 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
548
555
/**
549
556
* Check the spacing after the type of a parameter.
550
557
*
551
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
552
- * @param array $param The parameter to be checked.
553
- * @param int $maxType The maxlength of the longest parameter type.
554
- * @param int $spacing The number of spaces to add after the type.
558
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
559
+ * @param array $param The parameter to be checked.
560
+ * @param int $maxType The maxlength of the longest parameter type.
561
+ * @param int $spacing The number of spaces to add after the type.
555
562
*
556
563
* @return void
557
564
*/
558
- protected function checkSpacingAfterParamType (PHP_CodeSniffer_File $ phpcsFile , $ param , $ maxType , $ spacing = 1 )
565
+ protected function checkSpacingAfterParamType (File $ phpcsFile , $ param , $ maxType , $ spacing = 1 )
559
566
{
560
567
// Check number of spaces after the type.
561
568
$ spaces = ($ maxType - strlen ($ param ['type ' ]) + $ spacing );
@@ -602,14 +609,14 @@ protected function checkSpacingAfterParamType(PHP_CodeSniffer_File $phpcsFile, $
602
609
/**
603
610
* Check the spacing after the name of a parameter.
604
611
*
605
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
606
- * @param array $param The parameter to be checked.
607
- * @param int $maxVar The maxlength of the longest parameter name.
608
- * @param int $spacing The number of spaces to add after the type.
612
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
613
+ * @param array $param The parameter to be checked.
614
+ * @param int $maxVar The maxlength of the longest parameter name.
615
+ * @param int $spacing The number of spaces to add after the type.
609
616
*
610
617
* @return void
611
618
*/
612
- protected function checkSpacingAfterParamName (PHP_CodeSniffer_File $ phpcsFile , $ param , $ maxVar , $ spacing = 1 )
619
+ protected function checkSpacingAfterParamName (File $ phpcsFile , $ param , $ maxVar , $ spacing = 1 )
613
620
{
614
621
// Check number of spaces after the var name.
615
622
$ spaces = ($ maxVar - strlen ($ param ['var ' ]) + $ spacing );
0 commit comments