Issues (27)

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/Promise/PromiseFulfilled.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 Dazzle\Promise;
4
5
use Dazzle\Throwable\Exception\Logic\InvalidArgumentException;
6
use Error;
7
use Exception;
8
9
class PromiseFulfilled implements PromiseInterface
10
{
11
    /**
12
     * @var mixed|null
13
     */
14
    protected $value;
15
16
    /**
17
     * @param mixed|null $value
18
     * @throws InvalidArgumentException
19
     */
20 316
    public function __construct($value = null)
21
    {
22 316
        if ($value instanceof PromiseInterface)
23
        {
24 1
            throw new InvalidArgumentException(
25 1
                'You cannot create PromiseFulfilled with a promise. Use Promise::doResolve($promiseOrValue) instead.'
26
            );
27
        }
28
29 316
        $this->value = $value;
30 316
    }
31
32
    /**
33
     *
34
     */
35 290
    public function __destruct()
36
    {
37 290
        unset($this->value);
38 290
    }
39
40
    /**
41
     * @override
42
     * @inheritDoc
43
     */
44 222 View Code Duplication
    public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null)
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...
45
    {
46 222
        if (null === $onFulfilled)
47
        {
48 12
            return $this;
49
        }
50
51
        try
52
        {
53 215
            return Promise::doResolve($onFulfilled($this->getValue()));
54
        }
55 13
        catch (Error $ex)
56
        {
57
            return new PromiseRejected($ex);
58
        }
59 13
        catch (Exception $ex)
60
        {
61 13
            return new PromiseRejected($ex);
62
        }
63
    }
64
65
    /**
66
     * @override
67
     * @inheritDoc
68
     */
69 110
    public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null)
70
    {
71 110
        if (null === $onFulfilled)
72
        {
73
            return;
74
        }
75
76 110
        $result = $onFulfilled($this->getValue());
77
78 102
        if ($result instanceof PromiseInterface)
79
        {
80 5
            $result->done();
81
        }
82 97
    }
83
84
    /**
85
     * @override
86
     * @inheritDoc
87
     */
88 2
    public function spread(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null)
89
    {
90 2
        return $this->then(
91
            function($values) use($onFulfilled) {
92 2
                return $onFulfilled(...((array) $values));
93 2
            }
94
        );
95
    }
96
97
    /**
98
     * @override
99
     * @inheritDoc
100
     */
101 1
    public function success(callable $onSuccess)
102
    {
103 1
        return $this->then($onSuccess);
104
    }
105
106
    /**
107
     * @override
108
     * @inheritDoc
109
     */
110 2
    public function failure(callable $onFailure)
111
    {
112 2
        return $this->then(null, $onFailure);
113
    }
114
115
    /**
116
     * @override
117
     * @inheritDoc
118
     */
119 1
    public function abort(callable $onCancel)
120
    {
121 1
        return $this->then(null, null, $onCancel);
122
    }
123
124
    /**
125
     * @override
126
     * @inheritDoc
127
     */
128 5
    public function always(callable $onFulfilledOrRejected)
129
    {
130 5
        return $this->then(
131
            function($value) use($onFulfilledOrRejected) {
132 4
                return Promise::doResolve($onFulfilledOrRejected())->then(function() use($value) {
133 3
                    return $value;
134 4
                });
135 5
            }
136
        );
137
    }
138
139
    /**
140
     * @override
141
     * @inheritDoc
142
     */
143 1
    public function isPending()
144
    {
145 1
        return false;
146
    }
147
148
    /**
149
     * @override
150
     * @inheritDoc
151
     */
152 3
    public function isFulfilled()
153
    {
154 3
        return true;
155
    }
156
157
    /**
158
     * @override
159
     * @inheritDoc
160
     */
161 3
    public function isRejected()
162
    {
163 3
        return false;
164
    }
165
166
    /**
167
     * @override
168
     * @inheritDoc
169
     */
170 3
    public function isCancelled()
171
    {
172 3
        return false;
173
    }
174
175
    /**
176
     * @override
177
     * @inheritDoc
178
     */
179
    public function getPromise()
180
    {
181
        return $this;
182
    }
183
184
    /**
185
     * @override
186
     * @inheritDoc
187
     */
188
    public function resolve($value = null)
189
    {
190
        return $this;
191
    }
192
193
    /**
194
     * @override
195
     * @inheritDoc
196
     */
197
    public function reject($reason = null)
198
    {
199
        return $this;
200
    }
201
202
    /**
203
     * @override
204
     * @inheritDoc
205
     */
206 7
    public function cancel($reason = null)
207
    {
208 7
        return $this;
209
    }
210
211
    /**
212
     * @see Promise::getValue
213
     */
214 260
    protected function getValue()
215
    {
216 260
        return $this->value;
217
    }
218
219
    /**
220
     * @see Promise::getReason
221
     */
222
    protected function getReason()
223
    {
224
        return null;
225
    }
226
}
227