This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Collections\Traits; |
||
4 | |||
5 | use Collections\Exception\InvalidOperationException; |
||
6 | |||
7 | trait VectorLikeTrait |
||
8 | { |
||
9 | use ConstVectorLikeTrait, |
||
10 | CommonMutableContainerTrait; |
||
11 | |||
12 | /** |
||
13 | * identical to at, implemented for ArrayAccess |
||
14 | */ |
||
15 | public function offsetGet($offset) |
||
16 | { |
||
17 | return $this->at($offset); |
||
18 | } |
||
19 | |||
20 | public function offsetSet($offset, $value) |
||
21 | { |
||
22 | if (is_null($offset)) { |
||
23 | $this->add($value); |
||
24 | } else { |
||
25 | $this->set($offset, $value); |
||
26 | } |
||
27 | } |
||
28 | |||
29 | public function offsetUnset($offset) |
||
0 ignored issues
–
show
|
|||
30 | { |
||
31 | throw InvalidOperationException::unsupportedUnset($this); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Stores a value into the Vector with the specified key, overwriting the |
||
36 | * previous value associated with the key. If the key is not present, |
||
37 | * an exception is thrown. "$vec->set($k,$v)" is semantically equivalent |
||
38 | * to "$vec[$k] = $v" (except that set() returns the Vector). |
||
39 | * |
||
40 | * @param $key |
||
41 | * @param $value |
||
42 | * @return $this |
||
43 | */ |
||
44 | public function set($key, $value) |
||
45 | { |
||
46 | $this->validateKeyType($key); |
||
47 | $this->container[$key] = $value; |
||
48 | |||
49 | return $this; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | View Code Duplication | public function setAll($items) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
56 | { |
||
57 | $this->validateTraversable($items); |
||
58 | |||
59 | foreach ($items as $key => $item) { |
||
60 | if (is_array($item)) { |
||
61 | $item = new static($item); |
||
0 ignored issues
–
show
The call to
VectorLikeTrait::__construct() has too many arguments starting with $item .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
62 | } |
||
63 | $this->set($key, $item); |
||
64 | } |
||
65 | |||
66 | return $this; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function add($item) |
||
73 | { |
||
74 | $this->container[] = $item; |
||
75 | |||
76 | return $this; |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | public function removeKey($key) |
||
83 | { |
||
84 | $this->validateKeyType($key); |
||
85 | $this->validateKeyBounds($key); |
||
86 | |||
87 | array_splice($this->container, $key, 1); |
||
88 | |||
89 | return $this; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | public function splice($offset, $length = null) |
||
96 | { |
||
97 | if (!is_int($offset)) { |
||
98 | throw new \InvalidArgumentException('Parameter offset must be an integer'); |
||
99 | } |
||
100 | |||
101 | if (!is_null($length) && !is_int($length)) { |
||
102 | throw new \InvalidArgumentException('Parameter len must be null or an integer'); |
||
103 | } |
||
104 | |||
105 | $removed = is_null($length) ? array_splice($this->container, $offset) : |
||
0 ignored issues
–
show
$removed is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
106 | array_splice($this->container, $offset, $len); |
||
0 ignored issues
–
show
|
|||
107 | |||
108 | // if (count($removed) > 0) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
109 | // $this->hacklib_expireAllIterators(); |
||
110 | // } |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * {@inheritDoc} |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function each(callable $callable) |
||
118 | { |
||
119 | foreach ($this as $v) { |
||
0 ignored issues
–
show
|
|||
120 | $callable($v); |
||
121 | } |
||
122 | |||
123 | return $this; |
||
124 | } |
||
125 | } |
||
126 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.