Issues (4)

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/LightFsm/StateConfiguration.php (2 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 LightFsm;
4
5
class StateConfiguration
6
{
7
    /** @var string|int */
8
    private $state;
9
10
    /**
11
     * @var TransitionConfiguration[] event => TransitionConfiguration
12
     */
13
    private $transitions = [];
14
15
    /** @var callable[] */
16
    private $entryCallbacks = [];
17
18
    /** @var callable[] */
19
    private $exitCallbacks = [];
20
21
    /** @var string|int|null */
22
    private $parentState;
23
24
    /**
25
     * @param string|int $state
26
     */
27
    public function __construct($state)
28
    {
29
        $this->state = $state;
30
    }
31
32
    /**
33
     * @return string|int
34
     */
35
    public function getState()
36
    {
37
        return $this->state;
38
    }
39
40
    /**
41
     * @param string|int    $event
42
     * @param string|int    $nextState
43
     * @param callable|null $guardCallback f($data)
44
     * @param string|null   $guardName
45
     *
46
     * @return StateConfiguration
47
     */
48
    public function permit($event, $nextState, $guardCallback = null, $guardName = null)
49
    {
50
        $this->transitions[$event] = new TransitionConfiguration($this->state, $event, $nextState, $guardCallback, $guardName);
51
52
        return $this;
53
    }
54
55
    /**
56
     * @param string|int $parentState
57
     *
58
     * @return StateConfiguration
59
     */
60
    public function setParentState($parentState)
61
    {
62
        $this->parentState = $parentState;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return int|string|null
69
     */
70
    public function getParentState()
71
    {
72
        return $this->parentState;
73
    }
74
75
    /**
76
     * @param callable    $callback     f($isSubState, $data, $state)
77
     * @param string|null $listenerName
78
     *
79
     * @return StateConfiguration
80
     */
81
    public function onEntry($callback, $listenerName = null)
82
    {
83
        if ($listenerName) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $listenerName of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
84
            $this->entryCallbacks[$listenerName] = $callback;
85
        } else {
86
            $this->entryCallbacks[] = $callback;
87
        }
88
89
        return $this;
90
    }
91
92
    /**
93
     * @param callable    $callback     f($isSubState, $data, $state)
94
     * @param string|null $listenerName
95
     *
96
     * @return StateConfiguration
97
     */
98
    public function onExit($callback, $listenerName = null)
99
    {
100
        if ($listenerName) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $listenerName of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
101
            $this->exitCallbacks[$listenerName] = $callback;
102
        } else {
103
            $this->exitCallbacks[] = $callback;
104
        }
105
106
        return $this;
107
    }
108
109
    /**
110
     * @param string|int $event
111
     *
112
     * @return TransitionConfiguration|null
113
     */
114
    public function getTransition($event)
115
    {
116
        return isset($this->transitions[$event]) ? $this->transitions[$event ] : null;
117
    }
118
119
    /**
120
     * @return TransitionConfiguration[]
121
     */
122
    public function getAllTransitions()
123
    {
124
        return $this->transitions;
125
    }
126
127
    /**
128
     * @param bool  $isSubState
129
     * @param mixed $data
130
     */
131
    public function triggerEntry($isSubState, $data)
132
    {
133
        foreach ($this->entryCallbacks as $callback) {
134
            call_user_func($callback, $isSubState, $data, $this->state);
135
        }
136
    }
137
138
    /**
139
     * @param bool  $isSubState
140
     * @param mixed $data
141
     */
142
    public function triggerExit($isSubState, $data)
143
    {
144
        foreach ($this->exitCallbacks as $callback) {
145
            call_user_func($callback, $isSubState, $data, $this->state);
146
        }
147
    }
148
149
    /**
150
     * @return \callable[]
151
     */
152
    public function getAllEntryCallbacks()
153
    {
154
        return $this->entryCallbacks;
155
    }
156
157
    /**
158
     * @return \callable[]
159
     */
160
    public function getAllExitCallbacks()
161
    {
162
        return $this->exitCallbacks;
163
    }
164
}
165