Issues (55)

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/Reflection/Parts/InterfaceTrait.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 Benoth\StaticReflection\Reflection\Parts;
4
5
use Benoth\StaticReflection\Reflection\ReflectionInterface;
6
use Benoth\StaticReflection\ReflectionsIndex;
7
8
trait InterfaceTrait
9
{
10
    /**
11
     * @type string[]
12
     */
13
    protected $interfaces = [];
14
15
    /**
16
     * Must be implemented by classes using this trait
17
     */
18
    abstract public function getIndex();
19
20
    /**
21
     * Gets the interfaces, including inherited ones.
22
     *
23
     * @return ReflectionInterface[]
24
     */
25 417
    public function getInterfaces()
26
    {
27 417
        $interfaces = $this->getSelfInterfaces();
28
29 417
        foreach ($interfaces as $interface) {
30 123
            foreach ($interface->getInterfaces() as $parentInterface) {
31 123
                $interfaces[$parentInterface->getName()] = $parentInterface;
32 123
            }
33 417
        }
34
35 417
        return $interfaces;
36
    }
37
38
    /**
39
     * Gets the interfaces, without inherited ones.
40
     *
41
     * @return ReflectionInterface[]
42
     */
43 453 View Code Duplication
    public function getSelfInterfaces()
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...
44
    {
45 453
        $interfaces = [];
46
47 453
        if (!$this->getIndex() instanceof ReflectionsIndex) {
48
            return $interfaces;
49
        }
50
51 453
        foreach ($this->interfaces as $interface) {
52 303
            $interface = $this->getIndex()->getInterface($interface);
53 303
            if (!$interface instanceof ReflectionInterface) {
54 171
                continue;
55
            }
56 132
            $interfaces[$interface->getName()] = $interface;
57 453
        }
58
59 453
        return $interfaces;
60
    }
61
62
    /**
63
     * Gets the interfaces names, including inherited ones.
64
     *
65
     * @return string[] A numerical array with interface names as the values
66
     */
67 30
    public function getInterfaceNames()
68
    {
69 30
        $interfaces = $this->interfaces;
70
71 30
        foreach ($this->getInterfaces() as $interface) {
72 6
            if (!in_array($interface->getName(), $interfaces)) {
73 6
                $interfaces[] = $interface->getName();
74 6
            }
75 30
        }
76
77 30
        return $interfaces;
78
    }
79
80
    /**
81
     * Check whether current entity implements or extends an interface
82
     *
83
     * @param  string  $interfaceName The interface fully qualified name
84
     *
85
     * @return bool
86
     */
87
    public function hasInterface($interfaceName)
88
    {
89
        $interfaceName = ltrim($interfaceName, '\\');
90
        foreach ($this->getInterfaces() as $interface) {
91
            if ($interfaceName === $interface->getName()) {
92
                return true;
93
            }
94
        }
95
96
        return false;
97
    }
98
99
    /**
100
     * Add an interface.
101
     *
102
     * @param string $interface Fully Qualified Interface Name
103
     *
104
     * @return self
105
     */
106 708
    public function addInterface($interface)
107
    {
108 708
        $this->interfaces[] = $interface;
109
110 708
        return $this;
111
    }
112
}
113