Issues (12)

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 (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 Sergiors\Functional;
4
5
/**
6
 * @author Sérgio Rafael Siqueira <[email protected]>
7
 */
8
class Collection implements \ArrayAccess, \IteratorAggregate, \Countable
9
{
10
    /**
11
     * @var array
12
     */
13
    private $xs;
14
15
    /**
16
     * @param array $xs
17
     */
18 6
    public function __construct(array $xs)
19
    {
20 6
        $this->xs = $xs;
21 6
    }
22
23
    /**
24
     * @param array $xs
25
     *
26
     * @return Collection
27
     */
28 1
    public function concat($xs)
29
    {
30 1
        return new self(concat($this->xs, $xs));
31
    }
32
33
    /**
34
     * @param callable $fn
35
     *
36
     * @return Collection
37
     */
38 1
    public function filter(callable $fn)
39
    {
40 1
        return new self(filter($fn, $this->xs));
41
    }
42
43
    /**
44
     * @param callable $fn
45
     *
46
     * @return Collection
47
     */
48 1
    public function map(callable $fn)
49
    {
50 1
        return new self(map($fn, $this->xs));
51
    }
52
53
    /**
54
     * @param callable $fn
55
     *
56
     * @return Collection
57
     */
58 1
    public function each(callable $fn)
59
    {
60 1
        return new self(each($fn, $this->xs));
61
    }
62
63
    /**
64
     * @param mixed $x
65
     *
66
     * @return Collection
67
     */
68 1
    public function prepend($x)
69
    {
70 1
        return new self(prepend($x, $this->xs));
71
    }
72
73
    /**
74
     * @param mixed $x
75
     *
76
     * @return Collection
77
     */
78 1
    public function append($x)
79
    {
80 1
        return new self(append($x, $this->xs));
81
    }
82
83
    /**
84
     * @return Collection
85
     */
86 1
    public function sort()
87
    {
88 1
        return new self(sort($this->xs));
0 ignored issues
show
sort($this->xs) is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
89
    }
90
91
    /**
92
     * @param callable   $fn
93
     * @param mixed|null $initial
94
     *
95
     * @return mixed
96
     */
97 1
    public function reduce(callable $fn, $initial = null)
98
    {
99 1
        return reduce($fn, $this->xs, $initial);
100
    }
101
102
    /**
103
     * @return int
104
     */
105 1
    public function count()
106
    {
107 1
        return count($this->xs);
108
    }
109
110
    /**
111
     * @return \ArrayIterator
112
     */
113 1
    public function getIterator()
114
    {
115 1
        return new \ArrayIterator($this->xs);
116
    }
117
118
    /**
119
     * @return array
120
     */
121 3
    public function toArray()
122
    {
123 3
        return $this->xs;
124
    }
125
126
    /**
127
     * @param mixed $offset
128
     *
129
     * @return bool
130
     */
131 1
    public function offsetExists($offset)
132
    {
133 1
        return has($offset, $this->xs);
134
    }
135
136
    /**
137
     * @param mixed $offset
138
     *
139
     * @return mixed
140
     */
141 1
    public function offsetGet($offset)
142
    {
143 1
        return get($this->xs, $offset, null);
144
    }
145
146
    /**
147
     * @param mixed $offset
148
     *
149
     * @param mixed $x
150
     */
151 1
    public function offsetSet($offset, $x)
152
    {
153 1
        if (null === $offset) {
154 1
            $this->xs[] = $x;
155 1
            return;
156
        }
157
158 1
        $this->xs[$offset] = $x;
159 1
    }
160
161
    /**
162
     * @param mixed $offset
163
     */
164 1
    public function offsetUnset($offset)
165
    {
166 1
        if ($this->offsetExists($offset)) {
167 1
            unset($this->xs[$offset]);
168 1
        }
169 1
    }
170
}
171