1 | <?php |
||
19 | class SpaceAroundConcatSniff extends AbstractSniff |
||
20 | { |
||
21 | /** |
||
22 | * Error code for this sniff. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | public const CODE_MISSING_SPACE_AROUND_CONCAT = 'MissingSpaceAroundConcat'; |
||
27 | |||
28 | /** |
||
29 | * The message to the user for this error. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private const MESSAGE_MISSING_SPACE_AROUND_CONCAT = 'Please wrap your concatinations with a whitespace char.'; |
||
34 | |||
35 | /** |
||
36 | * Is the next token whitespace? |
||
37 | * |
||
38 | * @var bool|void |
||
39 | */ |
||
40 | private $nextIsWhitespace; |
||
41 | |||
42 | /** |
||
43 | * Is the prev token whitespace? |
||
44 | * |
||
45 | * @var void|bool |
||
46 | */ |
||
47 | private $prevIsWhitespace; |
||
48 | |||
49 | /** |
||
50 | * Adds whitespace around the concats. |
||
51 | * |
||
52 | * @param CodeWarning $warning |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | protected function fixDefaultProblem(CodeWarning $warning): void |
||
76 | |||
77 | /** |
||
78 | * Processes the token. |
||
79 | * |
||
80 | * @throws CodeError |
||
81 | * |
||
82 | * @return void |
||
83 | * |
||
84 | */ |
||
85 | protected function processToken(): void |
||
99 | |||
100 | /** |
||
101 | * Registers the tokens that this sniff wants to listen for. |
||
102 | * |
||
103 | * An example return value for a sniff that wants to listen for whitespace |
||
104 | * and any comments would be: |
||
105 | * |
||
106 | * <code> |
||
107 | * return array( |
||
108 | * T_WHITESPACE, |
||
109 | * T_DOC_COMMENT, |
||
110 | * T_COMMENT, |
||
111 | * ); |
||
112 | * </code> |
||
113 | * |
||
114 | * @return int[] |
||
115 | */ |
||
116 | public function register(): array |
||
120 | |||
121 | /** |
||
122 | * Sets up the sniff. |
||
123 | * |
||
124 | * @return void |
||
125 | */ |
||
126 | protected function setUp(): void |
||
136 | } |
||
137 |
If an expression can have both
false
, andnull
as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.