Issues (5)

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/AdvanceEventEmitterTrait.php (3 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 Thruster\Component\EventEmitter;
4
5
/**
6
 * Trait AdvanceEventEmitterTrait
7
 *
8
 * @package Thruster\Component\EventEmitter
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
trait AdvanceEventEmitterTrait
12
{
13
    /**
14
     * @var callable[]
15
     */
16
    protected $listeners = [];
17
18
    /**
19
     * @param string   $eventName
20
     * @param callable $listener
21
     *
22
     * @return $this
23
     */
24 14
    public function on(string $eventName, callable $listener) : self
25
    {
26 14
        $this->listeners[$eventName][] = $listener;
27
28 14
        return $this;
29
    }
30
31
    /**
32
     * @param string   $eventName
33
     * @param callable $listener
34
     *
35
     * @return $this
36
     */
37 View Code Duplication
    public function once(string $eventName, callable $listener) : self
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...
38
    {
39 2
        $onceListener = function (EventInterface $event) use (&$onceListener, $eventName, $listener) {
40 2
            $this->removeListener($eventName, $onceListener);
41
42 2
            call_user_func($listener, $event);
43 2
        };
44
45 2
        $this->on($eventName, $onceListener);
46
47 2
        return $this;
48
    }
49
50
    /**
51
     * @param string   $eventName
52
     * @param callable $listener
53
     *
54
     * @return $this
55
     */
56 4 View Code Duplication
    public function removeListener(string $eventName, callable $listener) : self
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...
57
    {
58 4
        if (array_key_exists($eventName, $this->listeners)) {
59 3
            $index = array_search($listener, $this->listeners[$eventName], true);
60
61 3
            if (false !== $index) {
62 3
                unset($this->listeners[$eventName][$index]);
63
            }
64
        }
65
66 4
        return $this;
67
    }
68
69
    /**
70
     * @param string $eventName
71
     *
72
     * @return $this
73
     */
74 3
    public function removeListeners(string $eventName = null) : self
75
    {
76 3
        if (null !== $eventName) {
77 2
            unset($this->listeners[$eventName]);
78
        } else {
79 1
            $this->listeners = [];
80
        }
81
82 3
        return $this;
83
    }
84
85
    /**
86
     * @param string $eventName
87
     *
88
     * @return array|callable[]
89
     */
90 12
    public function getListeners(string $eventName) : array
91
    {
92 12
        return isset($this->listeners[$eventName]) ? $this->listeners[$eventName] : [];
93
    }
94
95
    /**
96
     * @param string         $eventName
97
     * @param EventInterface $event
98
     *
99
     * @return $this
100
     */
101 12
    public function emit(string $eventName, EventInterface $event = null) : self
102
    {
103 12
        $event = $event ?? new Event();
104
105 12
        foreach ($this->getListeners($eventName) as $listener) {
106 8
            call_user_func($listener, $event);
107
108 8
            if (true == $event->isPropagationStopped()) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
109 8
                break;
110
            }
111
        }
112
113 12
        return $this;
114
    }
115
}
116