Issues (12)

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/CodeGenerator.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
 * Class Dumper
4
 *
5
 * @link      https://github.com/mtymek/class-dumper
6
 * @copyright Copyright (c) 2015 Mateusz Tymek
7
 * @license   BSD 2-Clause
8
 */
9
10
namespace ClassDumper;
11
12
use Zend\Code\Reflection\ClassReflection;
13
14
class CodeGenerator
15
{
16
    /**
17
     * @param ClassReflection $class
18
     * @return array
19
     */
20
    private function getUseArray(ClassReflection $class)
21
    {
22
        $usesNames = [];
23
        foreach ($class->getDeclaringFile()->getUses() as $use) {
24
            $usesNames[$use['use']] = $use['as'];
25
        }
26
        return $usesNames;
27
    }
28
29
    /**
30
     * @param ClassReflection $class
31
     * @return string
32
     */
33
    public function getUseLines(ClassReflection $class)
34
    {
35
        $useLines = [];
36
        foreach ($this->getUseArray($class) as $name => $as) {
37
            $useString = "use $name";
38
            if ($as) {
39
                $useString .= " as $as";
40
            }
41
            $useLines[] = $useString . ';';
42
        }
43
        return $useLines;
44
    }
45
46
    /**
47
     * @param ClassReflection $class
48
     * @param string $namespaceName
49
     * @param array $useArray
50
     * @return string
51
     */
52
    private function getClassNameInContext(ClassReflection $class, $namespaceName, $useArray)
53
    {
54
        if (!$namespaceName) {
55
            return '\\' . $class->getName();
56
        }
57
        return array_key_exists($class->getName(), $useArray)
58
            ? ($useArray[$class->getName()] ?: $class->getShortName())
59
            : ((0 === strpos($class->getName(), $namespaceName))
60
                ? substr($class->getName(), strlen($namespaceName) + 1)
61
                : '\\' . $class->getName());
62
    }
63
64
    /**
65
     * @param ClassReflection $class
66
     * @return string
67
     */
68
    public function getDeclarationLine(ClassReflection $class)
69
    {
70
        $usesNames = $this->getUseArray($class);
71
72
        $declaration = '';
73
        if ($class->isAbstract() && !$class->isInterface() && !$class->isTrait()) {
74
            $declaration .= 'abstract ';
75
        }
76
        if ($class->isFinal()) {
77
            $declaration .= 'final ';
78
        }
79
        if ($class->isInterface()) {
80
            $declaration .= 'interface ';
81
        } elseif ($class->isTrait()) {
82
            $declaration .= 'trait ';
83
        } else {
84
            $declaration .= 'class ';
85
        }
86
        $declaration .= $class->getShortName();
87
        $parentName = false;
88
        if ($parent = $class->getParentClass()) {
89
            $parentName = $this->getClassNameInContext($parent, $class->getNamespaceName(), $usesNames);
90
        }
91
        if ($parentName) {
92
            $declaration .= " extends {$parentName}";
93
        }
94
        $interfaces = array_diff($class->getInterfaceNames(), $parent ? $parent->getInterfaceNames() : array());
95
        if (count($interfaces)) {
96
            foreach ($interfaces as $interface) {
97
                $iReflection = new ClassReflection($interface);
98
                $interfaces  = array_diff($interfaces, $iReflection->getInterfaceNames());
99
            }
100
            $declaration .= $class->isInterface() ? ' extends ' : ' implements ';
101
            $declaration .= implode(', ', array_map(function($interface) use ($usesNames, $class) {
0 ignored issues
show
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
102
                $iReflection = new ClassReflection($interface);
103
                return $this->getClassNameInContext($iReflection, $class->getNamespaceName(), $usesNames);
104
            }, $interfaces));
105
        }
106
107
        return $declaration;
108
    }
109
}
110