Issues (168)

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/generator/Generic.php (11 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
//[PHPCOMPRESSOR(remove,start)]
3
/**
4
 * Created by Vitaly Iegorov <[email protected]>.
5
 * on 22.03.16 at 17:50
6
 */
7
namespace samsoncms\api\generator;
8
9
use samsonphp\generator\Generator;
10
11
/**
12
 * Generic object-oriented programming class generator.
13
 *
14
 * @package samsoncms\api\generator
15
 */
16
abstract class Generic
17
{
18
    /** @var string Generated class name */
19
    public $className;
20
21
    /** @var string Generated parent class */
22
    protected $parentClass;
23
24
    /** @var Generator Code generation instance */
25
    protected $generator;
26
27
    /** @var \samsoncms\api\generator\metadata\GenericMetadata Entity query Generic */
28
    protected $metadata;
29
30
    /**
31
     * OOP constructor.
32
     *
33
     * @param Generator                                         $generator Code generation instance
34
     * @param \samsoncms\api\generator\metadata\GenericMetadata $Generic   Entity query metadata
0 ignored issues
show
There is no parameter named $Generic. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
35
     */
36
    public function __construct(Generator $generator, $metadata)
37
    {
38
        $this->metadata = $metadata;
39
        $this->generator = $generator;
40
        $this->className = $metadata->entity;
41
    }
42
43
    /**
44
     * Generic class generation.
45
     *
46
     * @param Generic|metadata\GenericMetadata $metadata Entity metadata
47
     *
48
     * @return string Generated PHP class code
49
     */
50
    public function generate(Generic $metadata = null)
51
    {
52
        $metadata = null === $metadata ? $this->metadata : $metadata;
53
54
        $this->createUses($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\Generic::createUses() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
55
        $this->createDefinition($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\...ric::createDefinition() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
56
        $this->createConstants($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\Generic::createConstants() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
57
        $this->createStaticFields($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\...c::createStaticFields() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
58
        $this->createStaticMethods($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\...::createStaticMethods() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
59
        $this->createFields($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\Generic::createFields() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
60
        $this->createMethods($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\Generic::createMethods() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
61
        $this->createConstructor($metadata);
0 ignored issues
show
It seems like $metadata defined by null === $metadata ? $this->metadata : $metadata on line 52 can also be of type object<samsoncms\api\generator\Generic>; however, samsoncms\api\generator\...ic::createConstructor() does only seem to accept object<samsoncms\api\gen...tadata\GenericMetadata>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
62
63
        return $this->generator->endClass()->flush();
64
    }
65
66
    /**
67
     * Class uses generation part.
68
     *
69
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
70
     */
71
    protected function createUses($metadata)
0 ignored issues
show
The parameter $metadata is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
72
    {
73
74
    }
75
76
    /**
77
     * Class definition generation part.
78
     *
79
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
80
     */
81
    abstract protected function createDefinition($metadata);
82
83
    /**
84
     * Class constants generation part.
85
     *
86
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
87
     */
88
    protected function createConstants($metadata)
89
    {
90
91
    }
92
93
    /**
94
     * Class static fields generation part.
95
     *
96
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
97
     */
98
    protected function createStaticFields($metadata)
99
    {
100
101
    }
102
103
    /**
104
     * Class static methods generation part.
105
     *
106
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
107
     */
108
    protected function createStaticMethods($metadata)
0 ignored issues
show
The parameter $metadata is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
109
    {
110
111
    }
112
113
    /**
114
     * Class fields generation part.
115
     *
116
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
117
     */
118
    protected function createFields($metadata)
119
    {
120
121
    }
122
123
    /**
124
     * Class methods generation part.
125
     *
126
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
127
     */
128
    protected function createMethods($metadata)
129
    {
130
131
    }
132
133
    /**
134
     * Class constructor generation part.
135
     *
136
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
137
     */
138
    protected function createConstructor($metadata)
139
    {
140
141
    }
142
}
143
//[PHPCOMPRESSOR(remove,end)]
144