Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
LinksSet | |
0.00% |
0 / 19 |
|
0.00% |
0 / 4 |
156 | |
0.00% |
0 / 1 |
mergeWith | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
asMergedWith | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
withoutShape | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
asAllMovedToKeys | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
__toString | n/a |
0 / 0 |
n/a |
0 / 0 |
2 |
1 | <?php declare( strict_types=1 ); |
2 | |
3 | namespace SecurityCheckPlugin; |
4 | |
5 | use Phan\Language\Element\FunctionInterface; |
6 | use Phan\Library\Set; |
7 | |
8 | /** |
9 | * Convenience class for better type inference. |
10 | * |
11 | * @method SingleMethodLinks offsetGet( \Phan\Language\Element\FunctionInterface $object ) |
12 | * @method offsetSet( \Phan\Language\Element\FunctionInterface $object, SingleMethodLinks $data ) |
13 | * @method void attach(FunctionInterface $object, SingleMethodLinks $data) |
14 | * @method FunctionInterface current() |
15 | * @phan-file-suppress PhanParamSignatureMismatch,PhanParamSignaturePHPDocMismatchParamType |
16 | * @phan-file-suppress PhanParamSignaturePHPDocMismatchTooManyRequiredParameters |
17 | */ |
18 | class LinksSet extends Set { |
19 | /** |
20 | * @param self $other |
21 | */ |
22 | public function mergeWith( self $other ): void { |
23 | foreach ( $other as $method ) { |
24 | if ( $this->contains( $method ) ) { |
25 | $this[$method] = $this[$method]->asMergedWith( $other[$method] ); |
26 | } else { |
27 | $this->attach( $method, $other[$method] ); |
28 | } |
29 | } |
30 | } |
31 | |
32 | /** |
33 | * @param LinksSet $other |
34 | * @return self |
35 | */ |
36 | public function asMergedWith( self $other ): self { |
37 | $ret = clone $this; |
38 | $ret->mergeWith( $other ); |
39 | return $ret; |
40 | } |
41 | |
42 | public function withoutShape( self $other ): self { |
43 | $ret = clone $this; |
44 | foreach ( $other as $func ) { |
45 | if ( $ret->contains( $func ) ) { |
46 | $newFuncData = $ret[$func]->withoutShape( $other[$func] ); |
47 | if ( $newFuncData->getParams() ) { |
48 | $ret[$func] = $newFuncData; |
49 | } else { |
50 | unset( $ret[$func] ); |
51 | } |
52 | } |
53 | } |
54 | return $ret; |
55 | } |
56 | |
57 | /** |
58 | * @return self |
59 | */ |
60 | public function asAllMovedToKeys(): self { |
61 | $ret = new self; |
62 | foreach ( $this as $func ) { |
63 | $ret[$func] = $this[$func]->asAllParamsMovedToKeys(); |
64 | } |
65 | return $ret; |
66 | } |
67 | |
68 | /** |
69 | * @codeCoverageIgnore |
70 | */ |
71 | public function __toString(): string { |
72 | $children = []; |
73 | foreach ( $this as $func ) { |
74 | $children[] = $func->getFQSEN()->__toString() . ': ' . $this[$func]->__toString(); |
75 | } |
76 | return '{ ' . implode( ',', $children ) . ' }'; |
77 | } |
78 | } |