forked from ariddlestone/phpstan-cakephp2
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModelBehaviorMethodWrapper.php
More file actions
110 lines (91 loc) · 2.68 KB
/
Copy pathModelBehaviorMethodWrapper.php
File metadata and controls
110 lines (91 loc) · 2.68 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
declare(strict_types=1);
namespace PHPStanCakePHP2;
use PHPStan\Reflection\ClassMemberReflection;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\FunctionVariant;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptor;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Type;
/**
* Wraps {@link ModelBehavior} {@link MethodReflection}s to remove their first
* parameter (which should be the {@link Model}).
*/
final class ModelBehaviorMethodWrapper implements MethodReflection
{
private MethodReflection $wrappedMethod;
public function __construct(MethodReflection $wrappedMethod)
{
$this->wrappedMethod = $wrappedMethod;
}
public function getDeclaringClass(): ClassReflection
{
return $this->wrappedMethod->getDeclaringClass();
}
public function isStatic(): bool
{
return $this->wrappedMethod->isStatic();
}
public function isPrivate(): bool
{
return $this->wrappedMethod->isPrivate();
}
public function isPublic(): bool
{
return $this->wrappedMethod->isPublic();
}
public function getDocComment(): ?string
{
return $this->wrappedMethod->getDocComment();
}
public function getName(): string
{
return $this->wrappedMethod->getName();
}
public function getPrototype(): ClassMemberReflection
{
return $this->wrappedMethod->getPrototype();
}
/**
* @return array<ParametersAcceptor>
*/
public function getVariants(): array
{
return array_map(static function (ParametersAcceptor $variant) {
$parameters = $variant->getParameters();
array_shift($parameters);
return new FunctionVariant(
$variant->getTemplateTypeMap(),
$variant->getResolvedTemplateTypeMap(),
$parameters,
$variant->isVariadic(),
$variant->getReturnType()
);
}, $this->wrappedMethod->getVariants());
}
public function isDeprecated(): TrinaryLogic
{
return $this->wrappedMethod->isDeprecated();
}
public function getDeprecatedDescription(): ?string
{
return $this->wrappedMethod->getDeprecatedDescription();
}
public function isFinal(): TrinaryLogic
{
return $this->wrappedMethod->isFinal();
}
public function isInternal(): TrinaryLogic
{
return $this->wrappedMethod->isInternal();
}
public function getThrowType(): ?Type
{
return $this->wrappedMethod->getThrowType();
}
public function hasSideEffects(): TrinaryLogic
{
return $this->wrappedMethod->hasSideEffects();
}
}