Issues (99)

Security Analysis    not enabled

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/support/Fluent.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
namespace Childish\support;
3
4
use ArrayAccess;
5
use JsonSerializable;
6
7
/**
8
 * Fluent
9
 *
10
 * @author    Pu ShaoWei <[email protected]>
11
 * @date      2017/12/7
12
 * @package   Childish\support
13
 * @version   1.0
14
 */
15
class Fluent implements ArrayAccess, JsonSerializable
16
{
17
    /**
18
     * All of the attributes set on the container.
19
     *
20
     * @var array
21
     */
22
    protected $attributes = [];
23
24
    /**
25
     * Create a new fluent container instance.
26
     *
27
     * @param  array|object    $attributes
28
     * @return void|mixed
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
29
     */
30
    public function __construct($attributes = [])
31
    {
32
        foreach ($attributes as $key => $value) {
33
            $this->attributes[$key] = $value;
34
        }
35
    }
36
37
    /**
38
     * Get an attribute from the container.
39
     *
40
     * @param  string  $key
41
     * @param  mixed   $default
42
     * @return mixed
43
     */
44
    public function get($key, $default = null)
45
    {
46
        if (array_key_exists($key, $this->attributes)) {
47
            return $this->attributes[$key];
48
        }
49
50
        return $default instanceof \Closure ? $default() : $default;
51
52
    }
53
54
    /**
55
     * Get the attributes from the container.
56
     *
57
     * @return array
58
     */
59
    public function getAttributes()
60
    {
61
        return $this->attributes;
62
    }
63
64
    /**
65
     * Convert the Fluent instance to an array.
66
     *
67
     * @return array
68
     */
69
    public function toArray()
70
    {
71
        return $this->attributes;
72
    }
73
74
    /**
75
     * Convert the object into something JSON serializable.
76
     *
77
     * @return array
78
     */
79
    public function jsonSerialize()
80
    {
81
        return $this->toArray();
82
    }
83
84
    /**
85
     * Convert the Fluent instance to JSON.
86
     *
87
     * @param  int  $options
88
     * @return string
89
     */
90
    public function toJson($options = 0)
91
    {
92
        return json_encode($this->jsonSerialize(), $options);
93
    }
94
95
    /**
96
     * Determine if the given offset exists.
97
     *
98
     * @param  string  $offset
99
     * @return bool
100
     */
101
    public function offsetExists($offset)
102
    {
103
        return isset($this->attributes[$offset]);
104
    }
105
106
    /**
107
     * Get the value for a given offset.
108
     *
109
     * @param  string  $offset
110
     * @return mixed
111
     */
112
    public function offsetGet($offset)
113
    {
114
        return $this->get($offset);
115
    }
116
117
    /**
118
     * Set the value at the given offset.
119
     *
120
     * @param  string  $offset
121
     * @param  mixed   $value
122
     * @return void
123
     */
124
    public function offsetSet($offset, $value)
125
    {
126
        $this->attributes[$offset] = $value;
127
    }
128
129
    /**
130
     * Unset the value at the given offset.
131
     *
132
     * @param  string  $offset
133
     * @return void
134
     */
135
    public function offsetUnset($offset)
136
    {
137
        unset($this->attributes[$offset]);
138
    }
139
140
    /**
141
     * Handle dynamic calls to the container to set attributes.
142
     *
143
     * @param  string  $method
144
     * @param  array   $parameters
145
     * @return $this
146
     */
147
    public function __call($method, $parameters)
148
    {
149
        $this->attributes[$method] = count($parameters) > 0 ? $parameters[0] : true;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Dynamically retrieve the value of an attribute.
156
     *
157
     * @param  string  $key
158
     * @return mixed
159
     */
160
    public function __get($key)
161
    {
162
        return $this->get($key);
163
    }
164
165
    /**
166
     * Dynamically set the value of an attribute.
167
     *
168
     * @param  string  $key
169
     * @param  mixed   $value
170
     * @return void
171
     */
172
    public function __set($key, $value)
173
    {
174
        $this->offsetSet($key, $value);
175
    }
176
177
    /**
178
     * Dynamically check if an attribute is set.
179
     *
180
     * @param  string  $key
181
     * @return bool
182
     */
183
    public function __isset($key)
184
    {
185
        return $this->offsetExists($key);
186
    }
187
188
    /**
189
     * Dynamically unset an attribute.
190
     *
191
     * @param  string  $key
192
     * @return void
193
     */
194
    public function __unset($key)
195
    {
196
        $this->offsetUnset($key);
197
    }
198
}
199