|
9 | 9 |
|
10 | 10 | class PhpContentFilterTest extends TestCase |
11 | 11 | { |
12 | | - private const SAMPLE_CLASS = <<<'PHP' |
13 | | - <?php |
14 | | - namespace App\Example; |
15 | | - |
16 | | - use App\SomeClass; |
17 | | - use App\OtherClass; |
18 | | - |
19 | | - /** |
20 | | - * Sample class for testing the PHP content filter |
21 | | - */ |
22 | | - #[SomeAttribute] |
23 | | - class SampleClass |
24 | | - { |
25 | | - public const PUBLIC_CONST = 'public'; |
26 | | - protected const PROTECTED_CONST = 'protected'; |
27 | | - private const PRIVATE_CONST = 'private'; |
28 | | - |
29 | | - /** |
30 | | - * @var string |
31 | | - */ |
32 | | - #[Property] |
33 | | - public string $publicProperty = 'public'; |
34 | | - |
35 | | - /** |
36 | | - * @var string |
37 | | - */ |
38 | | - protected string $protectedProperty = 'protected'; |
39 | | - |
40 | | - /** |
41 | | - * @var string |
42 | | - */ |
43 | | - private string $privateProperty = 'private'; |
44 | | - |
45 | | - /** |
46 | | - * Constructor |
47 | | - */ |
48 | | - public function __construct( |
49 | | - public readonly string $name, |
50 | | - protected readonly int $age, |
51 | | - private readonly bool $active, |
52 | | - ) { |
53 | | - // Constructor implementation |
54 | | - } |
55 | | - |
56 | | - /** |
57 | | - * Public method |
58 | | - */ |
59 | | - #[Route('/')] |
60 | | - public function publicMethod(string $param): string |
61 | | - { |
62 | | - return "Public method with param: {$param}"; |
63 | | - } |
64 | | - |
65 | | - /** |
66 | | - * Protected method |
67 | | - */ |
68 | | - protected function protectedMethod(): void |
69 | | - { |
70 | | - // Protected method implementation |
71 | | - } |
72 | | - |
73 | | - /** |
74 | | - * Private method |
75 | | - */ |
76 | | - private function privateMethod(): bool |
77 | | - { |
78 | | - return true; |
79 | | - } |
80 | | - |
81 | | - /** |
82 | | - * Getter method |
83 | | - */ |
84 | | - public function getName(): string |
85 | | - { |
86 | | - return $this->name; |
87 | | - } |
88 | | - |
89 | | - /** |
90 | | - * Getter method |
91 | | - */ |
92 | | - public function getAge(): int |
93 | | - { |
94 | | - return $this->age; |
95 | | - } |
96 | | - |
97 | | - /** |
98 | | - * Getter method |
99 | | - */ |
100 | | - public function isActive(): bool |
101 | | - { |
102 | | - return $this->active; |
103 | | - } |
104 | | - } |
105 | | - PHP; |
| 12 | + private const SAMPLE_CLASS = <<<'PHP_WRAP' |
| 13 | + <?php |
| 14 | + namespace App\Example; |
| 15 | + |
| 16 | + use App\SomeClass; |
| 17 | + use App\OtherClass; |
| 18 | + |
| 19 | + /** |
| 20 | + * Sample class for testing the PHP content filter |
| 21 | + */ |
| 22 | + #[SomeAttribute] |
| 23 | + class SampleClass |
| 24 | + { |
| 25 | + public const PUBLIC_CONST = 'public'; |
| 26 | + protected const PROTECTED_CONST = 'protected'; |
| 27 | + private const PRIVATE_CONST = 'private'; |
| 28 | + |
| 29 | + /** |
| 30 | + * @var string |
| 31 | + */ |
| 32 | + #[Property] |
| 33 | + public string $publicProperty = 'public'; |
| 34 | + |
| 35 | + /** |
| 36 | + * @var string |
| 37 | + */ |
| 38 | + protected string $protectedProperty = 'protected'; |
| 39 | + |
| 40 | + /** |
| 41 | + * @var string |
| 42 | + */ |
| 43 | + private string $privateProperty = 'private'; |
| 44 | + |
| 45 | + /** |
| 46 | + * Constructor |
| 47 | + */ |
| 48 | + public function __construct( |
| 49 | + public readonly string $name, |
| 50 | + protected readonly int $age, |
| 51 | + private readonly bool $active, |
| 52 | + ) { |
| 53 | + // Constructor implementation |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Public method |
| 58 | + */ |
| 59 | + #[Route('/')] |
| 60 | + public function publicMethod(string $param): string |
| 61 | + { |
| 62 | + return "Public method with param: {$param}"; |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Protected method |
| 67 | + */ |
| 68 | + protected function protectedMethod(): void |
| 69 | + { |
| 70 | + // Protected method implementation |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Private method |
| 75 | + */ |
| 76 | + private function privateMethod(): bool |
| 77 | + { |
| 78 | + return true; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Getter method |
| 83 | + */ |
| 84 | + public function getName(): string |
| 85 | + { |
| 86 | + return $this->name; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Getter method |
| 91 | + */ |
| 92 | + public function getAge(): int |
| 93 | + { |
| 94 | + return $this->age; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Getter method |
| 99 | + */ |
| 100 | + public function isActive(): bool |
| 101 | + { |
| 102 | + return $this->active; |
| 103 | + } |
| 104 | + } |
| 105 | + PHP_WRAP; |
106 | 106 |
|
107 | 107 | public function testKeepOnlyPublicMethods(): void |
108 | 108 | { |
|
0 commit comments