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/Option.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Scalp;
6
7
use function Scalp\Conversion\AnyToString;
8
use Scalp\PatternMatching\CaseClass;
9
use Scalp\PatternMatching\Deconstruction;
10
use function Scalp\Type\restrictCallableReturnType;
0 ignored issues
show
The type Scalp\Type\restrictCallableReturnType 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...
11
use function Scalp\Utils\type;
0 ignored issues
show
The type Scalp\Utils\type 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...
12
13
abstract class Option implements CaseClass
14
{
15
    use Deconstruction;
16
17
    abstract public function isEmpty(): bool;
18
19
    final public function isDefined(): bool
20
    {
21
        return !$this->isEmpty();
22
    }
23
24
    abstract public function get();
25
26
    final public function getOrElse($default)
27
    {
28
        return $this->isEmpty() ? $default : $this->get();
29
    }
30
31
    final public function orNull()
32
    {
33
        return $this->getOrElse(null);
34
    }
35
36
    final public function map(callable $f): Option
37
    {
38
        return $this->isEmpty() ? $this : Some($f($this->get()));
39
    }
40
41
    final public function fold(callable $ifEmpty, callable $f)
42
    {
43
        return $this->isEmpty() ? $ifEmpty() : $f($this->get());
44
    }
45
46
    final public function flatMap($f): Option
47
    {
48
        restrictCallableReturnType($f, self::class);
49
50
        return $this->isEmpty() ? $this : $f($this->get());
51
    }
52
53
    final public function flatten(): Option
54
    {
55
        return $this->isDefined() && ($this->get() instanceof self) ? $this->get()->flatten() : $this;
56
    }
57
58
    final public function filter(callable $p): Option
59
    {
60
        return ($this->isEmpty() || $p($this->get())) ? $this : None();
61
    }
62
63
    final public function filterNot(callable $p): Option
64
    {
65
        return ($this->isEmpty() || !$p($this->get())) ? $this : None();
66
    }
67
68
    final public function contains($elem): bool
69
    {
70
        return !$this->isEmpty() && $this->get() === $elem;
71
    }
72
73
    final public function exists(callable $p): bool
74
    {
75
        return !$this->isEmpty() && $p($this->get());
76
    }
77
78
    final public function forall(callable $p): bool
79
    {
80
        return $this->isEmpty() || $p($this->get());
81
    }
82
83
    final public function foreach(callable $f): void
84
    {
85
        $this->isEmpty() ?: $f($this->get());
86
    }
87
88
    /**
89
     * This method should be implemented with PartialFunction
90
     * It should return the result of applying `pf` if it's
91
     * defined at option's value, None in other case.
92
     * In scala pf: PartialFunction[A,B] is lifted into A => Option[B].
93
     *
94
     * @param callable $pf
95
     *
96
     * @return Option
97
     */
98
    final public function collect(callable $pf): Option
99
    {
100
        return $this->flatMap($pf);
101
    }
102
103
    final public function orElse(Option $alternative): Option
104
    {
105
        return $this->isEmpty() ? $alternative : $this;
106
    }
107
108
    final public function iterator(): \Iterator
109
    {
110
        return $this->isEmpty() ? new \EmptyIterator() : new \ArrayIterator([$this->get()]);
111
    }
112
113
    /*
114
     * final public function toList(): List
115
     * final public function toRight($left)
116
     * final public function toLeft($right)
117
     */
118
119
    final public function toString(): string
120
    {
121
        return $this->isEmpty() ? 'None' : sprintf('Some[%s](%s)', type($this->get()), AnyToString($this->get()));
122
    }
123
124
    final public function __toString(): string
125
    {
126
        return $this->toString();
127
    }
128
}
129