Repository navigation
Expand file tree
/
Copy pathPureAbstractMethodRuleTest.php
More file actions
53 lines (47 loc) · 1.67 KB
/
Copy pathPureAbstractMethodRuleTest.php
File metadata and controls
53 lines (47 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Pure;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
/**
* @extends RuleTestCase<PureAbstractMethodRule>
*/
class PureAbstractMethodRuleTest extends RuleTestCase
{
public function getRule(): Rule
{
return new PureAbstractMethodRule(new FunctionPurityCheck());
}
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/pure-abstract-method.php'], [
[
'Method PureAbstractMethod\Foo::pureByRef() is marked as pure but parameter $p is passed by reference.',
11,
],
[
'Method PureAbstractMethod\Foo::pureVoid() is marked as pure but returns void.',
16,
],
[
'Method PureAbstractMethod\Foo::requiredCount() is marked @pure-unless-parameter-passed for parameter $count, but $count is not optional, so method PureAbstractMethod\Foo::requiredCount() is never pure.',
33,
],
[
'Method PureAbstractMethod\Foo::byValueFlag() is marked @pure-unless-parameter-passed for parameter $flag, but $flag is not passed by reference.',
38,
],
[
'Method PureAbstractMethod\Foo::alreadyPureCallback() is marked @pure-unless-callable-is-impure for parameter $cb, but $cb is already a pure callable, so method PureAbstractMethod\Foo::alreadyPureCallback() can be marked @phpstan-pure instead.',
50,
],
[
'Method PureAbstractMethod\Bar::pureByRef() is marked as pure but parameter $p is passed by reference.',
66,
],
[
'Method PureAbstractMethod\Bar::requiredCount() is marked @pure-unless-parameter-passed for parameter $count, but $count is not optional, so method PureAbstractMethod\Bar::requiredCount() is never pure.',
72,
],
]);
}
}