Issues (7)

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/TypedArray.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
namespace Ducatel\PHPCollection;
4
5
/**
6
 * This class represent a array which can contains only one type of object.
7
 * Characteristics:
8
 *
9
 *     - Values: Typed value, duplicates allowed
10
 *     - Ordering: same as input unless when explicitly sorted
11
 *
12
 * @package Ducatel\PHPCollection
13
 * @author  D.Ducatel
14
 */
15
class TypedArray extends Base\AbstractTypedCollection implements \ArrayAccess
16
{
17
    /**
18
     * Add an object to this collection
19
     *
20
     * @param object $object The object you want to add
21
     *
22
     * @param null|object $key The key where object will be stored. Null if you won't to use this as associative array
23
     *
24
     * @return True when added with success, else false
25
     */
26 10
    public function add($object, $key = null)
27
    {
28 10
        if ($this->validateType($object) === false) {
29 8
            return false;
30
        }
31
32 10
        if (is_null($key)) {
33 9
            $this->data[] = $object;
34
        } else {
35 1
            $this->data[$key] = $object;
36
        }
37
38 10
        return true;
39
    }
40
41
    /**
42
     * Add an object to this collection
43
     *
44
     * @param Integer $key The key (index) of object in the collection.
45
     *
46
     * @return false|object The deleted object or false if not found
47
     * @throws \TypeError Throw when key is not an integer
48
     */
49 2
    public function delete($key)
50
    {
51 2
        if (is_integer($key) === false) {
52 1
            throw new \TypeError("The key must be an integer");
0 ignored issues
show
The call to TypeError::__construct() has too many arguments starting with 'The key must be an integer'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
53
        }
54
55 1
        $result = array_splice($this->data, $key, 1);
56 1
        if (count($result) == 0) {
57 1
            return false;
58
        }
59
60 1
        return $result[0];
61
    }
62
63
64
65
    /**
66
     * Whether a offset exists
67
     *
68
     * @link  http://php.net/manual/en/arrayaccess.offsetexists.php
69
     *
70
     * @param mixed $offset <p>
71
     *                      An offset to check for.
72
     *                      </p>
73
     *
74
     * @return boolean true on success or false on failure.
75
     * </p>
76
     * <p>
77
     * The return value will be casted to boolean if non-boolean was returned.
78
     * @since 5.0.0
79
     */
80 2
    public function offsetExists($offset)
81
    {
82 2
        return isset($this->data[$offset]);
83
    }
84
85
    /**
86
     * Offset to retrieve
87
     *
88
     * @link  http://php.net/manual/en/arrayaccess.offsetget.php
89
     *
90
     * @param mixed $offset <p>
91
     *                      The offset to retrieve.
92
     *                      </p>
93
     *
94
     * @return mixed Can return all value types.
95
     * @since 5.0.0
96
     */
97 4
    public function offsetGet($offset)
98
    {
99 4
        return $this->data[$offset];
100
    }
101
102
    /**
103
     * Offset to set
104
     *
105
     * @link  http://php.net/manual/en/arrayaccess.offsetset.php
106
     *
107
     * @param mixed $offset The offset to assign the value to.
108
     * @param mixed $value  The value to set.
109
     *
110
     * @throws \TypeError When try to add type not managed by this collection
111
     * @since 5.0.0
112
     */
113 3 View Code Duplication
    public function offsetSet($offset, $value)
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...
114
    {
115 3
        if ($this->validateType($value) === false) {
116 1
            throw new \TypeError("Object cannot be added. Type not managed by this collection");
0 ignored issues
show
The call to TypeError::__construct() has too many arguments starting with 'Object cannot be added....ged by this collection'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
117
        }
118
119 3
        if (is_null($offset)) {
120 2
            $this->data[] = $value;
121
        } else {
122 2
            $this->data[$offset] = $value;
123
        }
124 3
    }
125
126
    /**
127
     * Offset to unset
128
     *
129
     * @link  http://php.net/manual/en/arrayaccess.offsetunset.php
130
     *
131
     * @param mixed $offset <p>
132
     *                      The offset to unset.
133
     *                      </p>
134
     *
135
     * @return void
136
     * @since 5.0.0
137
     */
138 1
    public function offsetUnset($offset)
139
    {
140 1
        unset($this->data[$offset]);
141 1
    }
142
}
143