|
| 1 | +<?php declare(strict_types = 1); |
| 2 | + |
| 3 | +namespace PHPStan\Rules\Debug; |
| 4 | + |
| 5 | +use PHPStan\PhpDocParser\Printer\Printer; |
| 6 | +use PHPStan\Rules\Rule; |
| 7 | +use PHPStan\Testing\RuleTestCase; |
| 8 | + |
| 9 | +/** |
| 10 | + * @extends RuleTestCase<DumpPhpDocTypeRule> |
| 11 | + */ |
| 12 | +class DumpPhpDocTypeRuleTest extends RuleTestCase |
| 13 | +{ |
| 14 | + |
| 15 | + protected function getRule(): Rule |
| 16 | + { |
| 17 | + return new DumpPhpDocTypeRule($this->createReflectionProvider(), new Printer()); |
| 18 | + } |
| 19 | + |
| 20 | + public function testRuleSymbols(): void |
| 21 | + { |
| 22 | + $this->analyse([__DIR__ . '/data/dump-phpdoc-type.php'], [ |
| 23 | + [ |
| 24 | + "Dumped type: array{'': ''}", |
| 25 | + 5, |
| 26 | + ], |
| 27 | + [ |
| 28 | + "Dumped type: array{'\0': 'NUL', NUL: '\0'}", |
| 29 | + 6, |
| 30 | + ], |
| 31 | + [ |
| 32 | + "Dumped type: array{'\001': 'SOH', SOH: '\001'}", |
| 33 | + 7, |
| 34 | + ], |
| 35 | + [ |
| 36 | + "Dumped type: array{'\t': 'HT', HT: '\t'}", |
| 37 | + 8, |
| 38 | + ], |
| 39 | + [ |
| 40 | + "Dumped type: array{' ': 'SP', SP: ' '}", |
| 41 | + 11, |
| 42 | + ], |
| 43 | + [ |
| 44 | + "Dumped type: array{'foo ': 'ends with SP', ' foo': 'starts with SP', ' foo ': 'surrounded by SP', foo: 'no SP'}", |
| 45 | + 12, |
| 46 | + ], |
| 47 | + [ |
| 48 | + "Dumped type: array{'foo?': 'foo?'}", |
| 49 | + 15, |
| 50 | + ], |
| 51 | + [ |
| 52 | + "Dumped type: array{shallwedance: 'yes'}", |
| 53 | + 16, |
| 54 | + ], |
| 55 | + [ |
| 56 | + "Dumped type: array{'shallwedance?': 'yes'}", |
| 57 | + 17, |
| 58 | + ], |
| 59 | + [ |
| 60 | + "Dumped type: array{'Shall we dance': 'yes'}", |
| 61 | + 18, |
| 62 | + ], |
| 63 | + [ |
| 64 | + "Dumped type: array{'Shall we dance?': 'yes'}", |
| 65 | + 19, |
| 66 | + ], |
| 67 | + [ |
| 68 | + "Dumped type: array{shall_we_dance: 'yes'}", |
| 69 | + 20, |
| 70 | + ], |
| 71 | + [ |
| 72 | + "Dumped type: array{'shall_we_dance?': 'yes'}", |
| 73 | + 21, |
| 74 | + ], |
| 75 | + [ |
| 76 | + "Dumped type: array{shall-we-dance: 'yes'}", |
| 77 | + 22, |
| 78 | + ], |
| 79 | + [ |
| 80 | + "Dumped type: array{'shall-we-dance?': 'yes'}", |
| 81 | + 23, |
| 82 | + ], |
| 83 | + [ |
| 84 | + "Dumped type: array{'Let\'s go': 'Let\'s go'}", |
| 85 | + 24, |
| 86 | + ], |
| 87 | + [ |
| 88 | + "Dumped type: array{Foo\\Bar: 'Foo\\\\Bar'}", |
| 89 | + 25, |
| 90 | + ], |
| 91 | + [ |
| 92 | + "Dumped type: array{'3.14': 3.14}", |
| 93 | + 26, |
| 94 | + ], |
| 95 | + [ |
| 96 | + 'Dumped type: array{1: true, 0: false}', |
| 97 | + 27, |
| 98 | + ], |
| 99 | + [ |
| 100 | + 'Dumped type: T', |
| 101 | + 36, |
| 102 | + ], |
| 103 | + ]); |
| 104 | + } |
| 105 | + |
| 106 | +} |
0 commit comments