Issues (88)

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.

ArrayCollection/ArrayList.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
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cubiche\Core\Collections\ArrayCollection;
12
13
use Cubiche\Core\Collections\DataSource\ArrayDataSource;
14
use Cubiche\Core\Collections\DataSourceList;
15
use Cubiche\Core\Collections\Exception\InvalidKeyException;
16
use Cubiche\Core\Comparable\Comparator;
17
use Cubiche\Core\Comparable\ComparatorInterface;
18
use Cubiche\Core\Specification\Criteria;
19
use Cubiche\Core\Specification\SpecificationInterface;
20
21
/**
22
 * ArrayList Class.
23
 *
24
 * @author Karel Osorio Ramírez <[email protected]>
25
 * @author Ivannis Suárez Jerez <[email protected]>
26
 */
27
class ArrayList extends ArrayCollection implements ArrayListInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function add($element)
33
    {
34
        $this->elements[] = $element;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function addAll($elements)
41
    {
42
        $this->validateTraversable($elements);
43
44
        foreach ($elements as $element) {
45
            $this->add($element);
46
        }
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function remove($element)
53
    {
54
        $criteria = Criteria::eq($element);
55
        foreach ($this->elements as $key => $value) {
56
            if ($criteria->evaluate($value)) {
57
                unset($this->elements[$key]);
58
                $this->elements = array_values($this->elements);
59
60
                return true;
61
            }
62
        }
63
64
        return false;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 View Code Duplication
    public function removeAll($elements)
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.

Loading history...
71
    {
72
        $this->validateTraversable($elements);
73
74
        $changed = false;
75
        foreach ($elements as $element) {
76
            if ($this->remove($element)) {
77
                $changed = true;
78
            }
79
        }
80
81
        return $changed;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function removeAt($key)
88
    {
89
        if ($this->hasKey($key)) {
90
            $removed = $this->elements[$key];
91
            unset($this->elements[$key]);
92
            $this->elements = array_values($this->elements);
93
94
            return $removed;
95
        }
96
97
        return;
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103 View Code Duplication
    public function contains($element)
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.

Loading history...
104
    {
105
        $criteria = Criteria::eq($element);
106
        foreach ($this->elements as $key => $value) {
107
            if ($criteria->evaluate($value)) {
108
                return true;
109
            }
110
        }
111
112
        return false;
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118
    public function indexOf($element)
119
    {
120
        $criteria = Criteria::eq($element);
121
        foreach ($this->elements as $key => $value) {
122
            if ($criteria->evaluate($value)) {
123
                return $key;
124
            }
125
        }
126
127
        return -1;
128
    }
129
130
    /**
131
     * {@inheritdoc}
132
     */
133 View Code Duplication
    public function sort(ComparatorInterface $criteria = null)
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.

Loading history...
134
    {
135
        if ($criteria === null) {
136
            $criteria = new Comparator();
137
        }
138
139
        uasort($this->elements, function ($a, $b) use ($criteria) {
140
            return $criteria->compare($a, $b);
141
        });
142
    }
143
144
    /**
145
     * {@inheritdoc}
146
     */
147
    public function sorted(ComparatorInterface $criteria)
148
    {
149
        return new DataSourceList(new ArrayDataSource($this->elements, null, $criteria));
150
    }
151
152
    /**
153
     * {@inheritdoc}
154
     */
155
    public function find(SpecificationInterface $criteria)
156
    {
157
        return new DataSourceList(new ArrayDataSource($this->elements, $criteria));
158
    }
159
160
    /**
161
     * {@inheritdoc}
162
     */
163
    public function findOne(SpecificationInterface $criteria)
164
    {
165
        return (new ArrayDataSource($this->elements, $criteria))->findOne();
166
    }
167
168
    /**
169
     * {@inheritdoc}
170
     */
171
    protected function validateKey($key)
172
    {
173
        if (!is_int($key)) {
174
            throw InvalidKeyException::forKey($key, 'Expected a key of type integer. Got: %s');
175
        }
176
177
        return true;
178
    }
179
180
    /**
181
     * {@inheritdoc}
182
     */
183
    public function offsetUnset($offset)
184
    {
185
        return $this->removeAt($offset);
186
    }
187
188
    /**
189
     * {@inheritdoc}
190
     */
191
    public function offsetSet($offset, $value)
192
    {
193
        $this->add($value);
194
    }
195
}
196