Issues (73)

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.

ClassMetadata.php (4 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\Metadata;
12
13
use Cubiche\Core\Collections\ArrayCollection\ArrayHashMap;
14
use Cubiche\Core\Collections\ArrayCollection\ArrayHashMapInterface;
15
16
/**
17
 * ClassMetadata class.
18
 *
19
 * @author Ivannis Suárez Jerez <[email protected]>
20
 */
21
class ClassMetadata implements \Serializable, ClassMetadataInterface
22
{
23
    /**
24
     * @var string
25
     */
26
    protected $className;
27
28
    /**
29
     * @var \ReflectionClass
30
     */
31
    protected $reflection;
32
33
    /**
34
     * @var ArrayHashMapInterface
35
     */
36
    protected $methodsMetadata;
37
38
    /**
39
     * @var ArrayHashMapInterface
40
     */
41
    protected $propertiesMetadata;
42
43
    /**
44
     * @var ArrayHashMapInterface
45
     */
46
    protected $metadata;
47
48
    /**
49
     * ClassMetadata constructor.
50
     *
51
     * @param string $className
52
     */
53
    public function __construct($className)
54
    {
55
        $this->className = $className;
56
57
        $this->reflection = new \ReflectionClass($className);
58
        $this->methodsMetadata = new ArrayHashMap();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Cubiche\Core\Collec...llection\ArrayHashMap() of type object<Cubiche\Core\Coll...ollection\ArrayHashMap> is incompatible with the declared type object<Cubiche\Core\Coll...\ArrayHashMapInterface> of property $methodsMetadata.

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...
59
        $this->propertiesMetadata = new ArrayHashMap();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Cubiche\Core\Collec...llection\ArrayHashMap() of type object<Cubiche\Core\Coll...ollection\ArrayHashMap> is incompatible with the declared type object<Cubiche\Core\Coll...\ArrayHashMapInterface> of property $propertiesMetadata.

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...
60
        $this->metadata = new ArrayHashMap();
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function className()
67
    {
68
        return $this->className;
69
    }
70
71
    /**
72
     * @return \ReflectionClass
73
     */
74
    public function reflection()
75
    {
76
        return $this->reflection;
77
    }
78
79
    /**
80
     * @return array
81
     */
82
    public function methodsMetadata()
83
    {
84
        return $this->methodsMetadata->toArray();
85
    }
86
87
    /**
88
     * @param MethodMetadata $metadata
89
     */
90
    public function addMethodMetadata(MethodMetadata $metadata)
91
    {
92
        $this->methodsMetadata->set($metadata->methodName(), $metadata);
93
    }
94
95
    /**
96
     * @param string $methodName
97
     *
98
     * @return MethodMetadata|null
99
     */
100
    public function methodMetadata($methodName)
101
    {
102
        return $this->methodsMetadata->get($methodName);
103
    }
104
105
    /**
106
     * @return array
107
     */
108
    public function propertiesMetadata()
109
    {
110
        return $this->propertiesMetadata->toArray();
111
    }
112
113
    /**
114
     * @param PropertyMetadata $metadata
115
     */
116
    public function addPropertyMetadata(PropertyMetadata $metadata)
117
    {
118
        $this->propertiesMetadata->set($metadata->propertyName(), $metadata);
119
    }
120
121
    /**
122
     * @param string $propertyName
123
     *
124
     * @return PropertyMetadata|null
125
     */
126
    public function propertyMetadata($propertyName)
127
    {
128
        return $this->propertiesMetadata->get($propertyName);
129
    }
130
131
    /**
132
     * @return array
133
     */
134
    public function metadata()
135
    {
136
        return $this->metadata->toArray();
137
    }
138
139
    /**
140
     * @param string $key
141
     * @param mixed  $value
142
     */
143
    public function addMetadata($key, $value)
144
    {
145
        $this->metadata->set($key, $value);
146
    }
147
148
    /**
149
     * @param string $key
150
     *
151
     * @return mixed|null
152
     */
153
    public function getMetadata($key)
154
    {
155
        return $this->metadata->get($key);
156
    }
157
158
    /**
159
     * @param ClassMetadataInterface $object
160
     *
161
     * @return ClassMetadataInterface
162
     */
163
    public function merge(ClassMetadataInterface $object)
164
    {
165
        $this->className = $object->className();
166
        $this->reflection = $object->reflection();
167
168
        foreach ($object->methodsMetadata() as $methodName => $metadata) {
169
            $this->addMethodMetadata($metadata);
170
        }
171
172
        foreach ($object->propertiesMetadata() as $propertyName => $metadata) {
173
            $this->addPropertyMetadata($metadata);
174
        }
175
176
        foreach ($object->metadata() as $key => $value) {
177
            $this->addMetadata($key, $value);
178
        }
179
    }
180
181
    /**
182
     * {@inheritdoc}
183
     */
184
    public function serialize()
185
    {
186
        return serialize(array(
187
            $this->className,
188
            $this->methodsMetadata->toArray(),
189
            $this->propertiesMetadata->toArray(),
190
            $this->metadata->toArray(),
191
        ));
192
    }
193
194
    /**
195
     * {@inheritdoc}
196
     */
197
    public function unserialize($str)
198
    {
199
        list(
200
            $this->className,
201
            $methodsMetadata,
202
            $propertiesMetadata,
203
            $metadata
204
        ) = unserialize($str);
205
206
        $this->reflection = new \ReflectionClass($this->className);
207
        $this->methodsMetadata = new ArrayHashMap($methodsMetadata);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Cubiche\Core\Collec...shMap($methodsMetadata) of type object<Cubiche\Core\Coll...ollection\ArrayHashMap> is incompatible with the declared type object<Cubiche\Core\Coll...\ArrayHashMapInterface> of property $methodsMetadata.

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...
208
        $this->propertiesMetadata = new ArrayHashMap($propertiesMetadata);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Cubiche\Core\Collec...ap($propertiesMetadata) of type object<Cubiche\Core\Coll...ollection\ArrayHashMap> is incompatible with the declared type object<Cubiche\Core\Coll...\ArrayHashMapInterface> of property $propertiesMetadata.

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...
209
        $this->metadata = new ArrayHashMap($metadata);
210
    }
211
}
212