Issues (4)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Barenote/Collection/ArrayCollection.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Barenote\Collection;
3
4
use ArrayIterator;
5
use Closure;
6
7
/**
8
 * Class ArrayCollection
9
 * @package Barenote\Collection
10
 */
11
class ArrayCollection implements \Countable, \IteratorAggregate, \ArrayAccess, \JsonSerializable
12
{
13
    /**
14
     * @var array
15
     */
16
    private $elements;
17
18
    /**
19
     * ArrayCollection constructor.
20
     * @param array $elements
21
     */
22
    public function __construct(array $elements = [])
23
    {
24
        $this->elements = $elements;
25
    }
26
27
    public function isEmpty()
28
    {
29
        return count($this->elements) == 0;
30
    }
31
32
    public function first()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
33
    {
34
        return reset($this->elements);
35
    }
36
    public function firstOrNull()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
37
    {
38
        if ($result = $this->first()) {
39
            return $result;
40
        }
41
        return null;
42
    }
43
44
    /**
45
     * @param $value
46
     */
47
    public function add($value)
48
    {
49
        $this->elements[] = $value;
50
    }
51
52
    /**
53
     * Clear the internal array
54
     */
55
    public function clear()
56
    {
57
        $this->elements = [];
58
    }
59
60
    /**
61
     * Checks if collection contains provided element.
62
     *
63
     * @param $element
64
     *
65
     * @return bool
66
     */
67
    public function contains($element)
68
    {
69
        return in_array($element, $this->elements, true);
70
    }
71
72
    public function getIterator()
73
    {
74
        return new ArrayIterator($this->elements);
75
    }
76
77
    public function offsetExists($offset)
78
    {
79
        return $this->containsKey($offset);
80
    }
81
82
    /**
83
     * Checks if collection contains provided key.
84
     *
85
     * @param $key
86
     *
87
     * @return bool
88
     */
89
    public function containsKey($key)
90
    {
91
        return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
92
    }
93
94
    public function offsetGet($offset)
95
    {
96
        return $this->get($offset);
97
    }
98
99
    /**
100
     * @param $key
101
     * @return mixed|null
102
     */
103
    public function get($key)
104
    {
105
        if (isset($this->elements[$key])) {
106
            return $this->elements[$key];
107
        }
108
109
        return null;
110
    }
111
112
    public function offsetSet($offset, $value)
113
    {
114
        $this->set($offset, $value);
115
    }
116
117
    /**
118
     * @param $key
119
     * @param $element
120
     */
121
    public function set($key, $element)
122
    {
123
        $this->elements[$key] = $element;
124
    }
125
126
    public function offsetUnset($offset)
127
    {
128
        $this->remove($offset);
129
    }
130
131
    public function remove($key)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
132
    {
133
        if (isset($this->elements[$key]) || array_key_exists($key, $this->elements)) {
134
            $removed = $this->elements[$key];
135
            unset($this->elements[$key]);
136
137
            return $removed;
138
        }
139
140
        return null;
141
    }
142
143
    public function count()
144
    {
145
        return count($this->elements);
146
    }
147
148
    public function jsonSerialize()
149
150
    {
151
        return $this->toArray();
152
    }
153
154
    /**
155
     * @return array
156
     */
157
    public function toArray()
158
    {
159
        return $this->elements;
160
    }
161
162
    /**
163
     * {@inheritdoc}
164
     */
165
    public function filter(Closure $p)
166
    {
167
        return new static(array_filter($this->elements, $p));
168
    }
169
170
    protected function extractProperties($propertyFetchMethod)
171
    {
172
        $values = [];
173
        $this->forAll(
174
            function ($entry) use (&$values, $propertyFetchMethod) {
175
                $values[] = $entry->{$propertyFetchMethod}();
176
            }
177
        );
178
179
        return $values;
180
    }
181
182
    /**
183
     * @param callable|Closure $p
184
     */
185
    public function forAll(Closure $p)
186
    {
187
        foreach ($this->elements as $key => $element) {
188
            $p($element, $key);
189
        }
190
    }
191
}