|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Test fixture. |
| 4 | + * |
| 5 | + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest |
| 6 | + */ |
| 7 | + |
| 8 | +namespace Fixtures\TestStandard\Sniffs\SetProperty; |
| 9 | + |
| 10 | +use PHP_CodeSniffer\Files\File; |
| 11 | +use PHP_CodeSniffer\Sniffs\Sniff; |
| 12 | + |
| 13 | +final class PropertyTypeHandlingSniff implements Sniff |
| 14 | +{ |
| 15 | + |
| 16 | + /** |
| 17 | + * Used to verify that string properties are set as string. |
| 18 | + * |
| 19 | + * This is the default behaviour. |
| 20 | + * |
| 21 | + * @var string |
| 22 | + */ |
| 23 | + public $expectsString; |
| 24 | + |
| 25 | + /** |
| 26 | + * Used to verify that a string value with only whitespace will end up being set as null. |
| 27 | + * |
| 28 | + * @var string|null |
| 29 | + */ |
| 30 | + public $emptyStringBecomesNull; |
| 31 | + |
| 32 | + /** |
| 33 | + * Used to verify that integer properties do not have special handling and will be set as a string. |
| 34 | + * |
| 35 | + * @var int |
| 36 | + */ |
| 37 | + public $expectsIntButAcceptsString; |
| 38 | + |
| 39 | + /** |
| 40 | + * Used to verify that floating point properties do not have special handling and will be set as a string. |
| 41 | + * |
| 42 | + * @var float |
| 43 | + */ |
| 44 | + public $expectsFloatButAcceptsString; |
| 45 | + |
| 46 | + /** |
| 47 | + * Used to verify that null gets set as a proper null value. |
| 48 | + * |
| 49 | + * @var null |
| 50 | + */ |
| 51 | + public $expectsNull; |
| 52 | + |
| 53 | + /** |
| 54 | + * Used to verify that null gets set as a proper null value. |
| 55 | + * |
| 56 | + * @var null |
| 57 | + */ |
| 58 | + public $expectsNullCase; |
| 59 | + |
| 60 | + /** |
| 61 | + * Used to verify that booleans get set as proper boolean values. |
| 62 | + * |
| 63 | + * @var bool |
| 64 | + */ |
| 65 | + public $expectsBooleanTrue; |
| 66 | + |
| 67 | + /** |
| 68 | + * Used to verify that booleans get set as proper boolean values. |
| 69 | + * |
| 70 | + * @var bool |
| 71 | + */ |
| 72 | + public $expectsBooleanTrueCase; |
| 73 | + |
| 74 | + /** |
| 75 | + * Used to verify that booleans get set as proper boolean values. |
| 76 | + * |
| 77 | + * @var bool |
| 78 | + */ |
| 79 | + public $expectsBooleanFalse; |
| 80 | + |
| 81 | + /** |
| 82 | + * Used to verify that booleans get set as proper boolean values. |
| 83 | + * |
| 84 | + * @var bool |
| 85 | + */ |
| 86 | + public $expectsBooleanFalseCase; |
| 87 | + |
| 88 | + /** |
| 89 | + * Used to verify that array properties get parsed to a proper array. |
| 90 | + * |
| 91 | + * @var array<mixed> |
| 92 | + */ |
| 93 | + public $expectsArrayWithOnlyValues; |
| 94 | + |
| 95 | + /** |
| 96 | + * Used to verify that array properties with keys get parsed to a proper array. |
| 97 | + * |
| 98 | + * @var array<string, mixed> |
| 99 | + */ |
| 100 | + public $expectsArrayWithKeysAndValues; |
| 101 | + |
| 102 | + /** |
| 103 | + * Used to verify that array properties passed as a string get parsed to a proper array. |
| 104 | + * |
| 105 | + * @var array<mixed> |
| 106 | + */ |
| 107 | + public $expectsOldSchoolArrayWithOnlyValues; |
| 108 | + |
| 109 | + /** |
| 110 | + * Used to verify that array properties passed as a string with keys get parsed to a proper array. |
| 111 | + * |
| 112 | + * @var array<string, mixed> |
| 113 | + */ |
| 114 | + public $expectsOldSchoolArrayWithKeysAndValues; |
| 115 | + |
| 116 | + public function register() |
| 117 | + { |
| 118 | + return [T_ECHO]; |
| 119 | + } |
| 120 | + |
| 121 | + public function process(File $phpcsFile, $stackPtr) |
| 122 | + { |
| 123 | + // Do something. |
| 124 | + } |
| 125 | +} |
0 commit comments