Issues (30)

Security Analysis    not enabled

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.

Entity/Menu.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 Alpixel\Bundle\MenuBundle\Entity;
4
5
use Alpixel\Bundle\MenuBundle\Model\ItemInterface;
6
use Alpixel\Bundle\MenuBundle\Model\MenuInterface;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\ORM\Mapping as ORM;
9
10
/**
11
 * @ORM\Table(name="alpixel_menu")
12
 * @ORM\Entity(repositoryClass="Alpixel\Bundle\MenuBundle\Entity\Repository\MenuRepository")
13
 */
14
class Menu implements MenuInterface
15
{
16
    /**
17
     * @var int
18
     *
19
     * @ORM\Column(name="menu_id", type="integer", nullable=false)
20
     * @ORM\Id
21
     * @ORM\GeneratedValue(strategy="IDENTITY")
22
     */
23
    protected $id;
24
25
    /**
26
     * @ORM\OneToMany(targetEntity="Alpixel\Bundle\MenuBundle\Entity\Item", mappedBy="menu", fetch="EAGER")
27
     * @ORM\OrderBy({"position": "ASC"})
28
     */
29
    protected $items;
30
31
    /**
32
     * @var string
33
     *
34
     * @ORM\Column(name="machine_name", type="string", length=255, nullable=false)
35
     */
36
    protected $machineName;
37
38
    /**
39
     * @var string
40
     *
41
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
42
     */
43
    protected $name;
44
45
    /**
46
     * @var string
47
     *
48
     * @ORM\Column(name="locale", type="string", length=10, nullable=false)
49
     */
50
    protected $locale;
51
52
    public function __construct()
53
    {
54
        $this->items = new ArrayCollection();
55
    }
56
57
    /**
58
     * Get string defined.
59
     *
60
     * @return string
61
     */
62
    public function __toString()
63
    {
64
        return $this->machineName;
65
    }
66
67
    /**
68
     * Get Id.
69
     *
70
     * @return int
71
     */
72
    public function getId()
73
    {
74
        return $this->id;
75
    }
76
77
    /**
78
     * Get the machineName the key for querying a menu.
79
     *
80
     * @return string
81
     */
82
    public function getMachineName()
83
    {
84
        return $this->machineName;
85
    }
86
87
    /**
88
     * Set the machineName the key for querying a menu.
89
     *
90
     * @param string
91
     *
92
     * @return self
93
     */
94
    public function setMachineName($machineName)
95
    {
96
        $this->machineName = $machineName;
97
98
        return $this;
99
    }
100
101
    /**
102
     * Get the name the value displayed to the administrator.
103
     *
104
     * @return self
105
     */
106
    public function getName()
107
    {
108
        return $this->name;
109
    }
110
111
    /**
112
     * Set the name the value displayed to the administrator.
113
     *
114
     * @return self
115
     */
116
    public function setName($name)
117
    {
118
        $this->name = $name;
119
120
        return $this;
121
    }
122
123
    /**
124
     * Get the items.
125
     *
126
     * @return ArrayCollection of Item object
127
     */
128
    public function getItems()
129
    {
130
        return $this->items;
131
    }
132
133
    /**
134
     * Remove Item obejct from ArrayCollection items.
135
     *
136
     * @param ItemInterface $item
137
     *
138
     * @return self
139
     */
140
    public function removeItem(ItemInterface $item)
141
    {
142
        if ($this->items->contains($item) === true) {
143
            $this->items->removeElement($item);
144
        }
145
146
        return $this;
147
    }
148
149
    /**
150
     * Add Items in items ArrayCollection.
151
     *
152
     * @param ArrayCollection of Item object $items
153
     *
154
     * @return self
155
     */
156
    public function addItems(ArrayCollection $items)
157
    {
158
        foreach ($items as $item) {
159
            if ($this->items->contains($item) === false) {
160
                $this->setItem($item);
161
            }
162
        }
163
164
        return $this;
165
    }
166
167
    /**
168
     * Set items for the menu.
169
     *
170
     * @deprecated
171
     *
172
     * @param null\ItemInterface $item
173
     *
174
     * @return Item
175
     */
176
    public function setItem(ItemInterface $item)
177
    {
178
        return $this->addItem($item);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->addItem($item); (Alpixel\Bundle\MenuBundle\Entity\Menu) is incompatible with the return type declared by the interface Alpixel\Bundle\MenuBundl...\MenuInterface::setItem of type Alpixel\Bundle\MenuBundle\Model\ItemInterface.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
179
    }
180
181
    /**
182
     * Set items for the menu.
183
     *
184
     * @param null\ItemInterface $item
185
     *
186
     * @return Item
187
     */
188
    public function addItem(ItemInterface $item)
189
    {
190
        $item->setMenu($this);
191
        $this->items->add($item);
192
193
        return $this;
194
    }
195
196
    /**
197
     * Get the locale language.
198
     *
199
     * @return string
200
     */
201
    public function getLocale()
202
    {
203
        return $this->locale;
204
    }
205
206
    /**
207
     * Set the locale language.
208
     *
209
     * @return self
210
     */
211
    public function setLocale($locale)
212
    {
213
        $this->locale = $locale;
214
215
        return $this;
216
    }
217
}
218