11<?php
22
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
411{
512 /**
613 * The current PHP version.
@@ -19,12 +26,12 @@ class Chadicus_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commen
1926 /**
2027 * Ensures only public methods are processed.
2128 *
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.
2431 *
2532 * @return void
2633 */
27- public function process (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr )
34+ public function process (File $ phpcsFile , $ stackPtr )
2835 {
2936 $ methodProperties = $ phpcsFile ->getMethodProperties ($ stackPtr );
3037 if ($ methodProperties ['scope ' ] !== 'public ' ) {
@@ -37,14 +44,14 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
3744 /**
3845 * Process the return comment of this function comment.
3946 *
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.
4451 *
4552 * @return void
4653 */
47- protected function processReturn (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr , $ commentStart )
54+ protected function processReturn (File $ phpcsFile , $ stackPtr , $ commentStart )
4855 {
4956 $ tokens = $ phpcsFile ->getTokens ();
5057
@@ -187,14 +194,14 @@ private function isReturnVoid($phpcsFile, $tokens, $stackPtr) : bool
187194 /**
188195 * Process any throw tags that this function comment has.
189196 *
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.
194201 *
195202 * @return void
196203 */
197- protected function processThrows (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr , $ commentStart )
204+ protected function processThrows (File $ phpcsFile , $ stackPtr , $ commentStart )
198205 {
199206 $ tokens = $ phpcsFile ->getTokens ();
200207
@@ -242,17 +249,17 @@ protected function processThrows(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
242249 /**
243250 * Process the function parameter comments.
244251 *
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.
249256 *
250257 * @return void
251258 */
252- protected function processParams (PHP_CodeSniffer_File $ phpcsFile , $ stackPtr , $ commentStart )
259+ protected function processParams (File $ phpcsFile , $ stackPtr , $ commentStart )
253260 {
254261 if ($ this ->_phpVersion === null ) {
255- $ this ->_phpVersion = PHP_CodeSniffer ::getConfigData ('php_version ' );
262+ $ this ->_phpVersion = Config ::getConfigData ('php_version ' );
256263 if ($ this ->_phpVersion === null ) {
257264 $ this ->_phpVersion = PHP_VERSION_ID ;
258265 }
@@ -388,7 +395,7 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
388395 $ suggestedTypeHint = 'callable ' ;
389396 } else if (strpos ($ suggestedName , 'callback ' ) !== false ) {
390397 $ suggestedTypeHint = 'callable ' ;
391- } else if (in_array ($ suggestedName , PHP_CodeSniffer ::$ allowedTypes ) === false ) {
398+ } else if (in_array ($ suggestedName , Common ::$ allowedTypes ) === false ) {
392399 $ suggestedTypeHint = $ suggestedName ;
393400 }
394401
@@ -548,14 +555,14 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
548555 /**
549556 * Check the spacing after the type of a parameter.
550557 *
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.
555562 *
556563 * @return void
557564 */
558- protected function checkSpacingAfterParamType (PHP_CodeSniffer_File $ phpcsFile , $ param , $ maxType , $ spacing = 1 )
565+ protected function checkSpacingAfterParamType (File $ phpcsFile , $ param , $ maxType , $ spacing = 1 )
559566 {
560567 // Check number of spaces after the type.
561568 $ spaces = ($ maxType - strlen ($ param ['type ' ]) + $ spacing );
@@ -602,14 +609,14 @@ protected function checkSpacingAfterParamType(PHP_CodeSniffer_File $phpcsFile, $
602609 /**
603610 * Check the spacing after the name of a parameter.
604611 *
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.
609616 *
610617 * @return void
611618 */
612- protected function checkSpacingAfterParamName (PHP_CodeSniffer_File $ phpcsFile , $ param , $ maxVar , $ spacing = 1 )
619+ protected function checkSpacingAfterParamName (File $ phpcsFile , $ param , $ maxVar , $ spacing = 1 )
613620 {
614621 // Check number of spaces after the var name.
615622 $ spaces = ($ maxVar - strlen ($ param ['var ' ]) + $ spacing );
0 commit comments