Issues (2)

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/Weew/Collections/Dictionary.php (1 issue)

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
namespace Weew\Collections;
4
5
use ArrayIterator;
6
use Weew\Contracts\IArrayable;
7
8
class Dictionary implements IDictionary {
9
    /**
10
     * @var array
11
     */
12
    protected $items;
13
14
    /**
15
     * @param array $items
16
     */
17
    public function __construct(array $items = []) {
18
        $this->setItems($items);
19
    }
20
21
    /**
22
     * @param $key
23
     * @param null $default
24
     *
25
     * @return mixed
26
     */
27
    public function get($key, $default = null) {
28
        return array_get($this->items, $key, $default);
29
    }
30
31
    /**
32
     * @param $key
33
     * @param mixed $value
34
     */
35
    public function set($key, $value) {
36
        array_set($this->items, $key, $value);
37
    }
38
39
    /**
40
     * @param $key
41
     */
42
    public function remove($key) {
43
        array_remove($this->items, $key);
44
    }
45
46
    /**
47
     * @param $key
48
     *
49
     * @return bool
50
     */
51
    public function has($key) {
52
        return array_has($this->items, $key);
53
    }
54
55
    /**
56
     * @param $key
57
     * @param null $default
58
     *
59
     * @return mixed
60
     */
61
    public function take($key, $default = null) {
62
        return array_take($this->items, $key, $default);
63
    }
64
65
    /**
66
     * @param $key
67
     * @param $value
68
     */
69
    public function add($key, $value) {
70
        array_add($this->items, $key, $value);
71
    }
72
73
    /**
74
     * @param array $items
75
     */
76
    public function merge(array $items) {
77
        foreach ($items as $key => $value) {
78
            $this->set($key, $value);
79
        }
80
    }
81
82
    /**
83
     * @param IDictionary $items
84
     */
85
    public function extend(IDictionary $items) {
86
        foreach ($items->getItems() as $key => $value) {
87
            $this->set($key, $value);
88
        }
89
    }
90
91
    /**
92
     * @return array
93
     */
94
    public function getItems() {
95
        return $this->items;
96
    }
97
98
    /**
99
     * @param array $items
100
     */
101
    public function setItems(array $items) {
102
        $this->items = $items;
103
    }
104
105
    /**
106
     * @return array
107
     */
108 View Code Duplication
    public function toArray() {
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...
109
        $array = [];
110
111
        foreach ($this->items as $key => $value) {
112
            if ($value instanceof IArrayable) {
113
                $value = $value->toArray();
114
            }
115
116
            $array[$key] = $value;
117
        }
118
119
        return $array;
120
    }
121
122
    /**
123
     * @return int
124
     */
125
    public function count() {
126
        return count($this->items);
127
    }
128
129
    /**
130
     * @param mixed $key
131
     *
132
     * @return mixed
133
     */
134
    public function offsetGet($key) {
135
        return $this->items[$key];
136
    }
137
138
    /**
139
     * @param mixed $key
140
     * @param mixed $value
141
     */
142
    public function offsetSet($key, $value) {
143
        $this->items[$key] = $value;
144
    }
145
146
    /**
147
     * @param mixed $key
148
     *
149
     * @return bool
150
     */
151
    public function offsetExists($key) {
152
        return array_key_exists($key, $this->items);
153
    }
154
155
    /**
156
     * @param mixed $key
157
     */
158
    public function offsetUnset($key) {
159
        if ($this->offsetExists($key)) {
160
            unset($this->items[$key]);
161
        }
162
    }
163
164
    /**
165
     * @return ArrayIterator
166
     */
167
    public function getIterator() {
168
        return new ArrayIterator($this->items);
169
    }
170
}
171