Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
76.47% covered (warning)
76.47%
13 / 17
80.00% covered (warning)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
LinksSet
76.47% covered (warning)
76.47%
13 / 17
80.00% covered (warning)
80.00%
4 / 5
11.30
0.00% covered (danger)
0.00%
0 / 1
 mergeWith
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 asMergedWith
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 asAllMovedToKeys
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 __toString
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 __clone
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php declare( strict_types=1 );
2
3namespace SecurityCheckPlugin;
4
5use Phan\Language\Element\FunctionInterface;
6use 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 */
18class 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]->mergeWith( $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    /**
43     * @return self
44     */
45    public function asAllMovedToKeys(): self {
46        $ret = new self;
47        foreach ( $this as $func ) {
48            $ret[$func] = $this[$func]->asAllParamsMovedToKeys();
49        }
50        return $ret;
51    }
52
53    public function __toString(): string {
54        $children = [];
55        foreach ( $this as $func ) {
56            $children[] = $func->getFQSEN()->__toString() . ': ' . $this[$func]->__toString();
57        }
58        return '{ ' . implode( ',', $children ) . ' }';
59    }
60
61    public function __clone() {
62        foreach ( $this as $func ) {
63            $this[$func] = clone $this[$func];
64        }
65    }
66}