Skip to content

Commit 25f45bc

Browse files
Add test
1 parent 514d912 commit 25f45bc

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/PHPStan/Rules/Pure/PureMethodRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ 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+
],
271275
]);
272276
}
273277

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,21 @@ 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+
* @phpstan-impure
168+
*/
169+
public function impureMethod(): mixed {
170+
return time();
171+
}
172+
}

0 commit comments

Comments
 (0)