@@ -69,7 +69,7 @@ abstract class AbstractArrayDeclarationSniff implements Sniff
6969 *
7070 * The array index is 1-based and contains the following information on each array item:
7171 * - 'start' : The stack pointer to the first token in the array item.
72- * - 'end' : The stack pointer to the first token in the array item.
72+ * - 'end' : The stack pointer to the last token in the array item.
7373 * - 'raw' : A string with the contents of all tokens between `start` and `end`.
7474 * - 'clean' : Same as `raw`, but all comment tokens have been stripped out.
7575 *
@@ -100,6 +100,8 @@ abstract class AbstractArrayDeclarationSniff implements Sniff
100100 /**
101101 * List of tokens which can safely be used with an eval() expression.
102102 *
103+ * This list gets enhanced with additional token groups in the constructor.
104+ *
103105 * @since 1.0.0
104106 *
105107 * @var array
@@ -203,7 +205,19 @@ final public function process(File $phpcsFile, $stackPtr)
203205 /**
204206 * Process every part of the array declaration.
205207 *
206- * This contains the default logic for the sniff, but can be overloaded in a concrete child class
208+ * Controller which calls the individual `process...()` methods for each part of the array.
209+ *
210+ * The method starts by calling the {@see AbstractArrayDeclarationSniff::processOpenClose()} method
211+ * and subsequently calls the following methods for each array item:
212+ *
213+ * Unkeyed arrays | Keyed arrays
214+ * -------------- | ------------
215+ * processNoKey() | processKey()
216+ * - | processArrow()
217+ * processValue() | processValue()
218+ * processComma() | processComma()
219+ *
220+ * This is the default logic for the sniff, but can be overloaded in a concrete child class
207221 * if needed.
208222 *
209223 * @since 1.0.0
@@ -265,7 +279,7 @@ public function processArray(File $phpcsFile)
265279 /**
266280 * Process the array opener and closer.
267281 *
268- * Optional method to be implemented in concrete child classes.
282+ * Optional method to be implemented in concrete child classes. By default, this method does nothing.
269283 *
270284 * @since 1.0.0
271285 *
@@ -277,6 +291,8 @@ public function processArray(File $phpcsFile)
277291 * @param int $closePtr The position of the array closer token in the token stack.
278292 *
279293 * @return true|void Returning `true` will short-circuit the sniff and stop processing.
294+ * In effect, this means that the sniff will not examine the individual
295+ * array items if `true` is returned.
280296 */
281297 public function processOpenClose (File $ phpcsFile , $ openPtr , $ closePtr )
282298 {
@@ -285,10 +301,10 @@ public function processOpenClose(File $phpcsFile, $openPtr, $closePtr)
285301 /**
286302 * Process the tokens in an array key.
287303 *
288- * Optional method to be implemented in concrete child classes.
304+ * Optional method to be implemented in concrete child classes. By default, this method does nothing.
289305 *
290- * The $startPtr and $endPtr do not discount whitespace or comments, but are all inclusive to
291- * allow examining all tokens in an array key.
306+ * Note: The ` $startPtr` and ` $endPtr` do not discount whitespace or comments, but are all inclusive
307+ * to allow for examining all tokens in an array key.
292308 *
293309 * @since 1.0.0
294310 *
@@ -306,6 +322,8 @@ public function processOpenClose(File $phpcsFile, $openPtr, $closePtr)
306322 * 1-based, i.e. the first item is item 1, the second 2 etc.
307323 *
308324 * @return true|void Returning `true` will short-circuit the array item loop and stop processing.
325+ * In effect, this means that the sniff will not examine the double arrow, the array
326+ * value or comma for this array item and will not process any array items after this one.
309327 */
310328 public function processKey (File $ phpcsFile , $ startPtr , $ endPtr , $ itemNr )
311329 {
@@ -314,12 +332,17 @@ public function processKey(File $phpcsFile, $startPtr, $endPtr, $itemNr)
314332 /**
315333 * Process an array item without an array key.
316334 *
317- * Optional method to be implemented in concrete child classes.
335+ * Optional method to be implemented in concrete child classes. By default, this method does nothing.
336+ *
337+ * Note: This method is _not_ intended for processing the array _value_. Use the
338+ * {@see AbstractArrayDeclarationSniff::processValue()} method to implement processing of the array value.
318339 *
319340 * @since 1.0.0
320341 *
321342 * @codeCoverageIgnore
322343 *
344+ * @see \PHPCSUtils\AbstractSniffs\AbstractArrayDeclarationSniff::processValue() Method to process the array value.
345+ *
323346 * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where the
324347 * token was found.
325348 * @param int $startPtr The stack pointer to the first token in the array item,
@@ -329,6 +352,8 @@ public function processKey(File $phpcsFile, $startPtr, $endPtr, $itemNr)
329352 * 1-based, i.e. the first item is item 1, the second 2 etc.
330353 *
331354 * @return true|void Returning `true` will short-circuit the array item loop and stop processing.
355+ * In effect, this means that the sniff will not examine the array value or
356+ * comma for this array item and will not process any array items after this one.
332357 */
333358 public function processNoKey (File $ phpcsFile , $ startPtr , $ itemNr )
334359 {
@@ -337,7 +362,7 @@ public function processNoKey(File $phpcsFile, $startPtr, $itemNr)
337362 /**
338363 * Process the double arrow.
339364 *
340- * Optional method to be implemented in concrete child classes.
365+ * Optional method to be implemented in concrete child classes. By default, this method does nothing.
341366 *
342367 * @since 1.0.0
343368 *
@@ -350,6 +375,8 @@ public function processNoKey(File $phpcsFile, $startPtr, $itemNr)
350375 * 1-based, i.e. the first item is item 1, the second 2 etc.
351376 *
352377 * @return true|void Returning `true` will short-circuit the array item loop and stop processing.
378+ * In effect, this means that the sniff will not examine the array value or
379+ * comma for this array item and will not process any array items after this one.
353380 */
354381 public function processArrow (File $ phpcsFile , $ arrowPtr , $ itemNr )
355382 {
@@ -358,10 +385,10 @@ public function processArrow(File $phpcsFile, $arrowPtr, $itemNr)
358385 /**
359386 * Process the tokens in an array value.
360387 *
361- * Optional method to be implemented in concrete child classes.
388+ * Optional method to be implemented in concrete child classes. By default, this method does nothing.
362389 *
363- * The $startPtr and $endPtr do not discount whitespace or comments, but are all inclusive to
364- * allow examining all tokens in an array value.
390+ * Note: The ` $startPtr` and ` $endPtr` do not discount whitespace or comments, but are all inclusive
391+ * to allow for examining all tokens in an array value.
365392 *
366393 * @since 1.0.0
367394 *
@@ -377,6 +404,8 @@ public function processArrow(File $phpcsFile, $arrowPtr, $itemNr)
377404 * 1-based, i.e. the first item is item 1, the second 2 etc.
378405 *
379406 * @return true|void Returning `true` will short-circuit the array item loop and stop processing.
407+ * In effect, this means that the sniff will not examine the comma for this
408+ * array item and will not process any array items after this one.
380409 */
381410 public function processValue (File $ phpcsFile , $ startPtr , $ endPtr , $ itemNr )
382411 {
@@ -385,7 +414,7 @@ public function processValue(File $phpcsFile, $startPtr, $endPtr, $itemNr)
385414 /**
386415 * Process the comma after an array item.
387416 *
388- * Optional method to be implemented in concrete child classes.
417+ * Optional method to be implemented in concrete child classes. By default, this method does nothing.
389418 *
390419 * @since 1.0.0
391420 *
@@ -398,6 +427,8 @@ public function processValue(File $phpcsFile, $startPtr, $endPtr, $itemNr)
398427 * 1-based, i.e. the first item is item 1, the second 2 etc.
399428 *
400429 * @return true|void Returning `true` will short-circuit the array item loop and stop processing.
430+ * In effect, this means that the sniff will not process any array items
431+ * after this one.
401432 */
402433 public function processComma (File $ phpcsFile , $ commaPtr , $ itemNr )
403434 {
@@ -406,7 +437,8 @@ public function processComma(File $phpcsFile, $commaPtr, $itemNr)
406437 /**
407438 * Determine what the actual array key would be.
408439 *
409- * Optional helper function for processsing array keys in the processKey() function.
440+ * Helper function for processsing array keys in the processKey() function.
441+ * Using this method is up to the sniff implementation in the child class.
410442 *
411443 * @since 1.0.0
412444 *
0 commit comments