Issues (6)

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/Collection.php (2 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 5.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Sinergi\Config;
4
5
require_once __DIR__ . "/DotenvHelper.php";
6
7
use InvalidArgumentException;
8
use ArrayAccess;
9
10
class Collection extends Configuration implements ArrayAccess
11
{
12
    /**
13
     * @param array|Configuration $config
14
     * @return Collection
15
     */
16
    public static function factory($config)
17
    {
18
        $factory = new Factory();
19
        return $factory($config);
20
    }
21
22
    /**
23
     * @var array
24
     */
25
    private $container = [];
26
27
    /**
28
     * Set a config
29
     *
30
     * @param string $name
31
     * @param array $config
32
     * @return $this
33
     */
34
    public function set($name, $config)
35
    {
36
        if (!isset($this->container[$name])) {
37
            $this->container[$name] = $config;
38
        } else {
39
            $this->container[$name] = array_merge($this->container[$name], $config);
40
        }
41
        return $this;
42
    }
43
44
    /**
45
     * @param string $name
46
     */
47
    public function remove($name)
48
    {
49
        unset($this->container[$name]);
50
    }
51
52
    /**
53
     * Get a config
54
     *
55
     * @param string $name
56
     * @param mixed $default
57
     * @throws InvalidArgumentException
58
     * @return mixed
59
     */
60
    public function get($name, $default = null)
61
    {
62
        if (!is_string($name) || empty($name)) {
63
            throw new InvalidArgumentException("Parameter \$name passed to Config::get() is not a valid string resource");
64
        }
65
66
        list($file, $key, $sub) = Parser::getKey($name);
67
68
        if (!isset($this->container[$file])) {
69
            $this->container[$file] = Loader::load(
70
                $this->paths,
71
                $this->environment,
72
                $file
73
            );
74
        }
75
76
        return Parser::getValue($this->container[$file], $key, $sub, $default);
77
    }
78
79
    /**
80
     * @return $this
81
     */
82
    public function reset()
83
    {
84
        $this->container = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $container.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
85
        return $this;
86
    }
87
88
    /**
89
     * @param string $name
90
     * @return mixed
91
     */
92
    public function __get($name)
93
    {
94
        return $this->offsetGet($name);
95
    }
96
97
    /**
98
     * @param string $name
99
     * @param array|null $args
100
     * @return mixed
101
     */
102
    public function __call($name, $args = null)
103
    {
104
        return $this->offsetGet($name);
105
    }
106
107
    /**
108
     * @param string $name
109
     * @return bool
110
     */
111
    public function __isset($name)
112
    {
113
        return $this->offsetExists($name);
114
    }
115
116
    /**
117
     * @param int $offset
118
     * @return bool
119
     */
120
    public function offsetExists($offset)
121
    {
122
        $item = $this->get($offset);
123
        return isset($item);
124
    }
125
126
    /**
127
     * @param int $offset
128
     * @return mixed
129
     */
130
    public function offsetGet($offset)
131
    {
132
        return $this->get($offset);
133
    }
134
135
    /**
136
     * @param int $offset
137
     * @param mixed $value
138
     */
139
    public function offsetSet($offset, $value)
140
    {
141
        $this->set($offset, $value);
142
    }
143
144
    /**
145
     * @param int $offset
146
     */
147
    public function offsetUnset($offset)
148
    {
149
        $this->remove($offset);
150
    }
151
}
152