File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
dev/tests/static/framework/Magento/Sniffs/MicroOptimizations Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2015 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Sniffs \MicroOptimizations ;
7
+
8
+ use PHP_CodeSniffer_File ;
9
+ use PHP_CodeSniffer_Sniff ;
10
+
11
+ class IsNullSniff implements PHP_CodeSniffer_Sniff
12
+ {
13
+ /**
14
+ * @var string
15
+ */
16
+ protected $ blacklist = 'is_null ' ;
17
+
18
+ /**
19
+ * @inheritdoc
20
+ */
21
+ public function register ()
22
+ {
23
+ return [T_STRING ];
24
+ }
25
+
26
+ /**
27
+ * @inheritdoc
28
+ */
29
+ public function process (PHP_CodeSniffer_File $ sourceFile , $ stackPtr )
30
+ {
31
+ $ tokens = $ sourceFile ->getTokens ();
32
+ if ($ tokens [$ stackPtr ]['content ' ] === $ this ->blacklist ) {
33
+ $ sourceFile ->addError ("is_null should be avoided. Use strict comparison instead. " , $ stackPtr );
34
+ }
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments