File tree Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,22 @@ public function testAllMethodsArePure(): void
244244'Method AllMethodsArePure\Bar::impure() is marked as impure but does not have any side effects. ' ,
24524548 ,
246246],
247+ [
248+ 'Impure call to method AllMethodsArePure\Test::impure() in pure method AllMethodsArePure\SideEffectPure::nothingWithImpure(). ' ,
249+ 78 ,
250+ ],
251+ [
252+ 'Method AllMethodsArePure\SideEffectPure::impureWithPure() is marked as impure but does not have any side effects. ' ,
253+ 88 ,
254+ ],
255+ [
256+ 'Method AllMethodsArePure\SideEffectImpure::nothingWithPure() is marked as impure but does not have any side effects. ' ,
257+ 101 ,
258+ ],
259+ [
260+ 'Impure call to method AllMethodsArePure\Test::impure() in pure method AllMethodsArePure\SideEffectImpure::pureWithImpure(). ' ,
261+ 106 ,
262+ ],
247263]);
248264}
249265
Original file line number Diff line number Diff line change @@ -49,3 +49,64 @@ function impure(): void
4949{
5050}
5151}
52+
53+ class Test
54+ {
55+ /**
56+ * @phpstan-impure
57+ */
58+ public static function impure (): void
59+ {
60+ }
61+
62+ /**
63+ * @phpstan-pure
64+ * @throws void
65+ */
66+ public static function pure (): int
67+ {
68+ return 1 ;
69+ }
70+ }
71+
72+ /**
73+ * @phpstan-all-methods-pure
74+ */
75+ final class SideEffectPure
76+ {
77+ public function nothingWithImpure (): int {
78+ Test::impure ();
79+ }
80+ public function nothingWithPure (): int {
81+ Test::pure ();
82+ }
83+ /** @phpstan-impure */
84+ public function impureWithImpure (): int {
85+ Test::impure ();
86+ }
87+ /** @phpstan-impure */
88+ public function impureWithPure (): int {
89+ Test::pure ();
90+ }
91+ }
92+
93+ /**
94+ * @phpstan-all-methods-impure
95+ */
96+ final class SideEffectImpure
97+ {
98+ public function nothingWithImpure (): int {
99+ Test::impure ();
100+ }
101+ public function nothingWithPure (): int {
102+ Test::pure ();
103+ }
104+ /** @phpstan-pure */
105+ public function pureWithImpure (): int {
106+ Test::impure ();
107+ }
108+ /** @phpstan-pure */
109+ public function pureWithPure (): int {
110+ Test::pure ();
111+ }
112+ }
You can’t perform that action at this time.
0 commit comments