|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. |
| 4 | + * |
| 5 | + * @package PHPCSUtils |
| 6 | + * @copyright 2019-2020 PHPCSUtils Contributors |
| 7 | + * @license https://opensource.org/licenses/LGPL-3.0 LGPL3 |
| 8 | + * @link https://github.com/PHPCSStandards/PHPCSUtils |
| 9 | + */ |
| 10 | + |
| 11 | +namespace PHPCSUtils\Internal; |
| 12 | + |
| 13 | +/** |
| 14 | + * Stable collections of related tokens. |
| 15 | + * |
| 16 | + * The {@see \PHPCSUtils\Tokens\Collections} class contains a range of token collections for use by sniffs, |
| 17 | + * some of which may change depending on the availability of a token in PHP/PHPCS. |
| 18 | + * The contents of token collections may also vary based on the PHPCS version to allow for optimized sniffing. |
| 19 | + * |
| 20 | + * The functionality _within_ PHPCSUtils, however, should be stable and reliably testable, so for internal |
| 21 | + * use, the most volatile token arrays are replicated here in stable versions to be used by the PHPCSUtils |
| 22 | + * functions (and tests) internally. |
| 23 | + * |
| 24 | + * --------------------------------------------------------------------------------------------- |
| 25 | + * This class is only intended for internal use by PHPCSUtils and is not part of the public API. |
| 26 | + * This also means that it has no promise of backward compatibility. |
| 27 | + * |
| 28 | + * End-users should use the methods in the {@see \PHPCSUtils\Tokens\Collections} class instead. |
| 29 | + * --------------------------------------------------------------------------------------------- |
| 30 | + * |
| 31 | + * @internal |
| 32 | + * |
| 33 | + * @since 1.0.0 |
| 34 | + */ |
| 35 | +final class StableCollections |
| 36 | +{ |
| 37 | + |
| 38 | + /** |
| 39 | + * Tokens which can open a short array or short list (PHPCS cross-version compatible). |
| 40 | + * |
| 41 | + * This array will ALWAYS include the `T_OPEN_SQUARE_BRACKET` token to allow for handling |
| 42 | + * intermittent tokenizer issues related to the retokenization to `T_OPEN_SHORT_ARRAY`. |
| 43 | + * |
| 44 | + * @internal |
| 45 | + * @ignore This array is only for internal use by PHPCSUtils and is not part of the public API. |
| 46 | + * |
| 47 | + * @since 1.0.2 |
| 48 | + * |
| 49 | + * @var array <int|string> => <int|string> |
| 50 | + */ |
| 51 | + public static $shortArrayListOpenTokensBC = [ |
| 52 | + \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, |
| 53 | + \T_OPEN_SQUARE_BRACKET => \T_OPEN_SQUARE_BRACKET, |
| 54 | + ]; |
| 55 | + |
| 56 | + /** |
| 57 | + * Tokens which are used for short lists. |
| 58 | + * |
| 59 | + * This array will ALWAYS include the `T_OPEN_SQUARE_BRACKET` and `T_CLOSE_SQUARE_BRACKET` tokens |
| 60 | + * to allow for handling intermittent tokenizer issues related to the retokenization to `T_OPEN_SHORT_ARRAY`. |
| 61 | + * |
| 62 | + * @internal |
| 63 | + * @ignore This array is only for internal use by PHPCSUtils and is not part of the public API. |
| 64 | + * |
| 65 | + * @since 1.0.2 |
| 66 | + * |
| 67 | + * @var array <int|string> => <int|string> |
| 68 | + */ |
| 69 | + public static $shortArrayListTokensBC = [ |
| 70 | + \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, |
| 71 | + \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY, |
| 72 | + \T_OPEN_SQUARE_BRACKET => \T_OPEN_SQUARE_BRACKET, |
| 73 | + \T_CLOSE_SQUARE_BRACKET => \T_CLOSE_SQUARE_BRACKET, |
| 74 | + ]; |
| 75 | +} |
0 commit comments