@@ -20,9 +20,9 @@ class CamelCapsFunctionNameSniff extends AbstractScopeSniff
2020 /**
2121 * A list of all PHP magic methods.
2222 *
23- * @var array
23+ * @var array<string, true>
2424 */
25- protected $ magicMethods = [
25+ protected const MAGIC_METHODS = [
2626 'construct ' => true ,
2727 'destruct ' => true ,
2828 'call ' => true ,
@@ -47,9 +47,9 @@ class CamelCapsFunctionNameSniff extends AbstractScopeSniff
4747 *
4848 * These come from PHP modules such as SOAPClient.
4949 *
50- * @var array
50+ * @var array<string, true>
5151 */
52- protected $ methodsDoubleUnderscore = [
52+ protected const DOUBLE_UNDERSCORE_METHODS = [
5353 'dorequest ' => true ,
5454 'getcookies ' => true ,
5555 'getfunctions ' => true ,
@@ -67,9 +67,9 @@ class CamelCapsFunctionNameSniff extends AbstractScopeSniff
6767 /**
6868 * A list of all PHP magic functions.
6969 *
70- * @var array
70+ * @var array<string, true>
7171 */
72- protected $ magicFunctions = ['autoload ' => true ];
72+ protected const MAGIC_FUNCTIONS = ['autoload ' => true ];
7373
7474 /**
7575 * If TRUE, the string must not have two capital letters next to each other.
@@ -78,6 +78,33 @@ class CamelCapsFunctionNameSniff extends AbstractScopeSniff
7878 */
7979 public $ strict = true ;
8080
81+ /**
82+ * A list of all PHP magic methods.
83+ *
84+ * @var array<string, true>
85+ *
86+ * @deprecated 4.0.0 Use the CamelCapsFunctionNameSniff::MAGIC_METHODS constant instead.
87+ */
88+ protected $ magicMethods = self ::MAGIC_METHODS ;
89+
90+ /**
91+ * A list of all PHP non-magic methods starting with a double underscore.
92+ *
93+ * @var array<string, true>
94+ *
95+ * @deprecated 4.0.0 Use the CamelCapsFunctionNameSniff::DOUBLE_UNDERSCORE_METHODS constant instead.
96+ */
97+ protected $ methodsDoubleUnderscore = self ::DOUBLE_UNDERSCORE_METHODS ;
98+
99+ /**
100+ * A list of all PHP magic functions.
101+ *
102+ * @var array<string, true>
103+ *
104+ * @deprecated 4.0.0 Use the CamelCapsFunctionNameSniff::MAGIC_FUNCTIONS constant instead.
105+ */
106+ protected $ magicFunctions = self ::MAGIC_FUNCTIONS ;
107+
81108
82109 /**
83110 * Constructs a Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
@@ -130,8 +157,8 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
130157 // Is this a magic method. i.e., is prefixed with "__" ?
131158 if (preg_match ('|^__[^_]| ' , $ methodName ) !== 0 ) {
132159 $ magicPart = substr ($ methodNameLc , 2 );
133- if (isset ($ this -> magicMethods [$ magicPart ]) === true
134- || isset ($ this -> methodsDoubleUnderscore [$ magicPart ]) === true
160+ if (isset (static :: MAGIC_METHODS [$ magicPart ]) === true
161+ || isset (static :: DOUBLE_UNDERSCORE_METHODS [$ magicPart ]) === true
135162 ) {
136163 return ;
137164 }
@@ -197,7 +224,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
197224 // Is this a magic function. i.e., it is prefixed with "__".
198225 if (preg_match ('|^__[^_]| ' , $ functionName ) !== 0 ) {
199226 $ magicPart = strtolower (substr ($ functionName , 2 ));
200- if (isset ($ this -> magicFunctions [$ magicPart ]) === true ) {
227+ if (isset (static :: MAGIC_FUNCTIONS [$ magicPart ]) === true ) {
201228 return ;
202229 }
203230
0 commit comments