Issues (56)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Scalp/Utils/TryCatch.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Scalp\Utils;
6
7
use Scalp\Option;
8
9
abstract class TryCatch
10
{
11
    /**
12
     * Returns `true` if the `TryCatch` is a `Failure`, `false` otherwise.
13
     *
14
     * def isFailure: Boolean
15
     *
16
     * @return bool
17
     */
18
    abstract public function isFailure(): bool;
19
20
    /**
21
     * Returns `true` if the `TryCatch` is a `Success`, `false` otherwise.
22
     *
23
     * def isSuccess: Boolean
24
     *
25
     * @return bool
26
     */
27
    abstract public function isSuccess(): bool;
28
29
    /**
30
     * Returns the value from this `Success` or the given `default` argument if this is a `Failure`.
31
     *
32
     * ''Note:'': This will throw an exception if it is not a success and default throws an exception.
33
     *
34
     * def getOrElse[U >: T](default: => U): U
35
     *
36
     * @param mixed $default
37
     *
38
     * @return mixed
39
     */
40
    abstract public function getOrElse($default);
41
42
    /**
43
     * Returns this `TryCatch` if it's a `Success` or the given `default` argument if this is a `Failure`.
44
     *
45
     * def orElse[U >: T](default: => Try[U]): Try[U]
46
     *
47
     * @param TryCatch $default
48
     *
49
     * @return TryCatch
50
     */
51
    abstract public function orElse(TryCatch $default): TryCatch;
52
53
    /**
54
     * Returns the value from this `Success` or throws the exception if this is a `Failure`.
55
     *
56
     * def get: T
57
     *
58
     * @return mixed
59
     */
60
    abstract public function get();
61
62
    /**
63
     * Applies the given function `f` if this is a `Success`, otherwise returns `Unit` if this is a `Failure`.
64
     *
65
     * ''Note:'' If `f` throws, then this method may throw an exception.
66
     *
67
     * def foreach[U](f: T => U): Unit
68
     *
69
     * @param callable $f
70
     */
71
    abstract public function foreach(callable $f): void;
72
73
    /**
74
     * Returns the given function applied to the value from this `Success` or returns this if this is a `Failure`.
75
     *
76
     * def flatMap[U](f: T => Try[U]): Try[U]
77
     *
78
     * @param callable $f
79
     *
80
     * @return TryCatch
81
     */
82
    abstract public function flatMap(callable $f): TryCatch;
83
84
    /*
85
     * Maps the given function to the value from this `Success` or returns this if this is a `Failure`.
86
     *
87
     * def map[U](f: T => U): Try[U]
88
     *
89
     * @param callable $f
90
     * @return TryCatch
91
     */
92
    abstract public function map(callable $f): TryCatch;
93
94
    /*
95
     * Applies the given partial function to the value from this `Success` or returns this if this is a `Failure`.
96
     *
97
     * def collect[U](pf: PartialFunction[T, U]): Try[U]
98
     *
99
     * @param PartialFunction $f
100
     * @return TryCatch
101
     */
102
//    abstract public function collect(PartialFunction $pf): TryCatch;
103
104
    /*
105
     * Converts this to a `Failure` if the predicate is not satisfied.
106
     *
107
     * def filter(p: T => Boolean): Try[T]
108
     *
109
     * @param callable $p
110
     * @return TryCatch
111
     */
112
    abstract public function filter(callable $p): TryCatch;
113
114
    /* Creates a non-strict filter, which eventually converts this to a `Failure`
115
     *  if the predicate is not satisfied.
116
     *
117
     *  Note: unlike filter, withFilter does not create a new Try.
118
     *        Instead, it restricts the domain of subsequent
119
     *        `map`, `flatMap`, `foreach`, and `withFilter` operations.
120
     *
121
     * As Try is a one-element collection, this may be a bit overkill,
122
     * but it's consistent with withFilter on Option and the other collections.
123
     *
124
     *  [@]param p the predicate used to test elements.
125
     *  [@]return  an object of class `WithFilter`, which supports
126
     *             `map`, `flatMap`, `foreach`, and `withFilter` operations.
127
     *             All these operations apply to those elements of this Try
128
     *             which satisfy the predicate `p`.
129
     *
130
     * [@]inline final def withFilter(p: T => Boolean): WithFilter = new WithFilter(p)
131
     *
132
     * @param callable $p
133
     * @return WithFilter
134
     */
135
//    abstract public function withFilter(callable $p): WithFilter;
136
137
    /*
138
     * Applies the given function `f` if this is a `Failure`, otherwise returns this if this is a `Success`.
139
     * This is like `flatMap` for the exception.
140
     *
141
     * def recoverWith[U >: T](@deprecatedName('f) pf: PartialFunction[Throwable, Try[U]]): Try[U]
0 ignored issues
show
The type Scalp\Utils\PartialFunction was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
142
     *
143
     * @param PartialFunction $pf
144
     * @return TryCatch
145
     */
146
//    abstract public function recoverWith(PartialFunction $pf): TryCatch;
147
    abstract public function recoverWith(callable $pf): TryCatch;
148
149
    /*
150
     * Applies the given function `f` if this is a `Failure`, otherwise returns this if this is a `Success`.
151
     * This is like map for the exception.
152
     *
153
     * def recover[U >: T](@deprecatedName('f) pf: PartialFunction[Throwable, U]): Try[U]
154
     *
155
     * @param PartialFunction $pf
156
     * @return TryCatch
157
     */
158
//    abstract public function recover(PartialFunction $pf): TryCatch;
159
    abstract public function recover(callable $pf): TryCatch;
160
161
    /*
162
     * Returns `None` if this is a `Failure` or a `Some` containing the value if this is a `Success`.
163
     *
164
     * def toOption: Option[T]
165
     */
166
    abstract public function toOption(): Option;
167
168
    /*
169
     * Transforms a nested `Try`, ie, a `Try` of type `Try[Try[T]]`,
170
     * into an un-nested `Try`, ie, a `Try` of type `Try[T]`.
171
     *
172
     * def flatten[U](implicit ev: T <:< Try[U]): Try[U]
173
     */
174
    abstract public function flatten(): TryCatch;
175
176
    /*
177
     * Inverts this `Try`. If this is a `Failure`, returns its exception wrapped in a `Success`.
178
     * If this is a `Success`, returns a `Failure` containing an `UnsupportedOperationException`.
179
     *
180
     * def failed: Try[Throwable]
181
     */
182
    abstract public function failed(): TryCatch;
183
184
    /*
185
     * Completes this `Try` by applying the function `f` to this if this is of type `Failure`, or conversely, by applying
186
     * `s` if this is a `Success`.
187
     *
188
     * def transform[U](s: T => Try[U], f: Throwable => Try[U]): Try[U]
189
     */
190
    abstract public function transform(callable $s, callable $f): TryCatch;
191
192
    /*
193
     * Returns `Left` with `Throwable` if this is a `Failure`, otherwise returns `Right` with `Success` value.
194
     *
195
     * def toEither: Either[Throwable, T]
196
     */
197
//    abstract public function toEither(): Either;
198
199
    /*
200
     * Applies `fa` if this is a `Failure` or `fb` if this is a `Success`.
201
     * If `fb` is initially applied and throws an exception,
202
     * then `fa` is applied with this exception.
203
     *
204
     * @example {{{
205
     * val result: Try[Throwable, Int] = Try { string.toInt }
206
     * log(result.fold(
207
     *   ex => "Operation failed with " + ex,
208
     *   v => "Operation produced value: " + v
209
     * ))
210
     * }}}
211
     *
212
     * def fold[U](fa: Throwable => U, fb: T => U): U
213
     */
214
    abstract public function fold(callable $fa, callable $fb);
215
}
216