Skip to content

Commit 9923c7a

Browse files
Add test
1 parent 514d912 commit 9923c7a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/PHPStan/Rules/Pure/PureMethodRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ public function testAllMethodsArePure(): void
268268
'Impure call to method AllMethodsArePure\Test::impure() in pure method AllMethodsArePure\SideEffectImpure::pureWithImpure().',
269269
148,
270270
],
271+
[
272+
'Impure call to method AllMethodsArePure\FooWithMixed::impureMethod() in pure method AllMethodsArePure\FooWithMixed::testMixed().',
273+
163,
274+
],
275+
[
276+
'Impure call to method AllMethodsArePure\FooWithMixed::impureMethod() in pure method AllMethodsArePure\FooWithMixed::testMixed2().',
277+
171,
278+
],
271279
]);
272280
}
273281

tests/PHPStan/Rules/Pure/data/all-methods-are-pure.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,29 @@ public function pureWithPure(): int {
152152
Test::pure();
153153
}
154154
}
155+
156+
/**
157+
* @phpstan-all-methods-pure
158+
*/
159+
final class FooWithMixed
160+
{
161+
public function testMixed(): mixed
162+
{
163+
return $this->impureMethod();
164+
}
165+
166+
/**
167+
* @return mixed
168+
*/
169+
public function testMixed2()
170+
{
171+
return $this->impureMethod();
172+
}
173+
174+
/**
175+
* @phpstan-impure
176+
*/
177+
public function impureMethod(): mixed {
178+
return time();
179+
}
180+
}

0 commit comments

Comments
 (0)