Issues (1039)

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.

src/Entity/QuizAnswer.php (10 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
namespace PlaygroundGame\Entity;
3
4
use Doctrine\ORM\Mapping as ORM;
5
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
6
use Doctrine\ORM\Mapping\PrePersist;
7
use Doctrine\ORM\Mapping\PreUpdate;
8
use Zend\InputFilter\InputFilter;
9
use Zend\InputFilter\Factory as InputFactory;
10
use Zend\InputFilter\InputFilterAwareInterface;
11
use Zend\InputFilter\InputFilterInterface;
12
use Gedmo\Mapping\Annotation as Gedmo;
13
14
/**
15
 * @ORM\Entity @HasLifecycleCallbacks
16
 * @ORM\Table(name="game_quiz_answer")
17
 * @Gedmo\TranslationEntity(class="PlaygroundGame\Entity\QuizAnswerTranslation")
18
 */
19
class QuizAnswer implements InputFilterAwareInterface
20
{
21
    protected $inputFilter;
22
23
    /**
24
     * @ORM\Id
25
     * @ORM\Column(type="integer");
26
     * @ORM\GeneratedValue(strategy="AUTO")
27
     */
28
    protected $id;
29
30
    /**
31
     * @ORM\ManyToOne(targetEntity="QuizQuestion", inversedBy="answers")
32
     *
33
     **/
34
    protected $question;
35
36
    /**
37
     * @Gedmo\Translatable
38
     * @ORM\Column(type="text", nullable=true)
39
     */
40
    protected $answer;
41
42
    /**
43
     * Explanation of the answer
44
     * @Gedmo\Translatable
45
     * @ORM\Column(type="text", nullable=true)
46
     */
47
    protected $explanation;
48
49
    /**
50
     * @Gedmo\Translatable
51
     * @ORM\Column(name="json_data", type="text", nullable=true)
52
     */
53
    protected $jsonData;
54
55
    /**
56
     * @Gedmo\Translatable
57
     * @ORM\Column(type="string", nullable=true)
58
     */
59
    protected $video;
60
61
    /**
62
     * @Gedmo\Translatable
63
     * @ORM\Column(type="string", nullable=true)
64
     */
65
    protected $image;
66
67
    /**
68
     * The answer score in the game
69
     * @ORM\Column(type="integer", nullable=true)
70
     */
71
    protected $points = 0;
72
73
    /**
74
     * @ORM\Column(type="integer", nullable=false)
75
     */
76
    protected $position = 0;
77
78
    /**
79
     *
80
     * @ORM\Column(type="boolean", nullable=true)
81
     */
82
    protected $correct = 0;
83
84
    /**
85
     * @ORM\Column(type="datetime")
86
     */
87
    protected $created_at;
88
89
    /**
90
     * @ORM\Column(type="datetime")
91
     */
92
    protected $updated_at;
93
94
    /** @PrePersist */
95
    public function createChrono()
96
    {
97
        $this->created_at = new \DateTime("now");
98
        $this->updated_at = new \DateTime("now");
99
    }
100
101
    /** @PreUpdate */
102
    public function updateChrono()
103
    {
104
        $this->updated_at = new \DateTime("now");
105
    }
106
107
    /**
108
     * @return the unknown_type
109
     */
110
    public function getId()
111
    {
112
        return $this->id;
113
    }
114
115
    /**
116
     * @param unknown_type $id
117
     */
118
    public function setId($id)
119
    {
120
        $this->id = $id;
121
122
        return $this;
123
    }
124
125
    /**
126
     * @return the unknown_type
127
     */
128
    public function getQuestion()
129
    {
130
        return $this->question;
131
    }
132
133
    /**
134
     * @param unknown_type $question
135
     */
136
    public function setQuestion($question)
137
    {
138
        $this->question = $question;
139
140
        return $this;
141
    }
142
143
    /**
144
     * @return the unknown_type
145
     */
146
    public function getAnswer()
147
    {
148
        return $this->answer;
149
    }
150
151
    /**
152
     * @param unknown_type $answer
153
     */
154
    public function setAnswer($answer)
155
    {
156
        $this->answer = $answer;
157
158
        return $this;
159
    }
160
161
    /**
162
     * @return the unknown_type
163
     */
164
    public function getExplanation()
165
    {
166
        return $this->explanation;
167
    }
168
169
    /**
170
     * @param unknown_type $explanation
171
     */
172
    public function setExplanation($explanation)
173
    {
174
        $this->explanation = $explanation;
175
176
        return $this;
177
    }
178
179
    /**
180
     * @return the string
181
     */
182
    public function getJsonData()
183
    {
184
        return $this->jsonData;
185
    }
186
187
    /**
188
     * @param string $hint
0 ignored issues
show
There is no parameter named $hint. 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...
189
     */
190
    public function setJsonData($jsonData)
191
    {
192
        $this->jsonData = $jsonData;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @return the unknown_type
199
     */
200
    public function getVideo()
201
    {
202
        return $this->video;
203
    }
204
205
    /**
206
     * @param unknown_type $video
207
     */
208
    public function setVideo($video)
209
    {
210
        $this->video = $video;
211
212
        return $this;
213
    }
214
215
    /**
216
     * @return the unknown_type
217
     */
218
    public function getImage()
219
    {
220
        return $this->image;
221
    }
222
223
    /**
224
     * @param unknown_type $image
225
     */
226
    public function setImage($image)
227
    {
228
        $this->image = $image;
229
230
        return $this;
231
    }
232
233
    /**
234
     * @return integer unknown_type
235
     */
236
    public function getPoints()
237
    {
238
        return $this->points;
239
    }
240
241
    /**
242
     * @param unknown_type $points
243
     */
244
    public function setPoints($points)
245
    {
246
        $this->points = $points;
0 ignored issues
show
Documentation Bug introduced by
It seems like $points of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type integer of property $points.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
247
248
        return $this;
249
    }
250
251
    /**
252
     * @return integer unknown_type
253
     */
254
    public function getPosition()
255
    {
256
        return $this->position;
257
    }
258
259
    /**
260
     * @param unknown_type $position
261
     */
262
    public function setPosition($position)
263
    {
264
        $this->position = $position;
0 ignored issues
show
Documentation Bug introduced by
It seems like $position of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type integer of property $position.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
265
266
        return $this;
267
    }
268
269
    /**
270
     * @return integer unknown_type
271
     */
272
    public function getCorrect()
273
    {
274
        return $this->correct;
275
    }
276
277
    /**
278
     * @param unknown_type $correct
279
     */
280
    public function setCorrect($correct)
281
    {
282
        $this->correct = $correct;
0 ignored issues
show
Documentation Bug introduced by
It seems like $correct of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type integer of property $correct.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
283
284
        return $this;
285
    }
286
287
    /**
288
     * @return the unknown_type
289
     */
290
    public function getCreatedAt()
291
    {
292
        return $this->created_at;
293
    }
294
295
    /**
296
     * @param unknown_type $created_at
297
     */
298
    public function setCreatedAt($created_at)
299
    {
300
        $this->created_at = $created_at;
301
302
        return $this;
303
    }
304
305
    /**
306
     * @return the unknown_type
307
     */
308
    public function getUpdatedAt()
309
    {
310
        return $this->updated_at;
311
    }
312
313
    /**
314
     * @param unknown_type $updated_at
315
     */
316
    public function setUpdatedAt($updated_at)
317
    {
318
        $this->updated_at = $updated_at;
319
320
        return $this;
321
    }
322
323
    /**
324
     * Convert the object to an array.
325
     *
326
     * @return array
327
     */
328
    public function getArrayCopy()
329
    {
330
        $obj_vars = get_object_vars($this);
331
332
        return $obj_vars;
333
    }
334
335
    /**
336
     * Populate from an array.
337
     *
338
     * @param array $data
339
     */
340
    public function populate($data = array())
341
    {
342
        if (isset($data['answer']) && $data['answer'] !== null) {
343
            $this->answer = $data['answer'];
344
        }
345
346
        if (isset($data['explanation']) && $data['explanation'] !== null) {
347
            $this->explanation = $data['explanation'];
348
        }
349
350 View Code Duplication
        if (isset($data['jsonData']) && $data['jsonData'] !== null) {
0 ignored issues
show
This code seems to be duplicated across 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...
351
            $this->jsonData = $data['jsonData'];
352
        }
353
354 View Code Duplication
        if (isset($data['type']) && $data['type'] !== null) {
0 ignored issues
show
This code seems to be duplicated across 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...
355
            $this->type = $data['type'];
0 ignored issues
show
The property type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
356
        }
357
358 View Code Duplication
        if (isset($data['position']) && $data['position'] !== null) {
0 ignored issues
show
This code seems to be duplicated across 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...
359
            $this->position = $data['position'];
360
        }
361
362 View Code Duplication
        if (isset($data['image']) && $data['image'] !== null) {
0 ignored issues
show
This code seems to be duplicated across 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...
363
            $this->image = $data['image'];
364
        }
365
366 View Code Duplication
        if (isset($data['video']) && $data['video'] !== null) {
0 ignored issues
show
This code seems to be duplicated across 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...
367
            $this->video = $data['video'];
368
        }
369
370
        if (isset($data['points']) && $data['points'] !== null) {
371
            $this->points = $data['points'];
372
        }
373
374
        if (isset($data['correct']) && $data['correct'] !== null) {
375
            $this->correct = $data['correct'];
376
        }
377
    }
378
379
    public function setInputFilter(InputFilterInterface $inputFilter)
380
    {
381
        throw new \Exception("Not used");
382
    }
383
384
    public function getInputFilter()
385
    {
386
        if (!$this->inputFilter) {
387
            $inputFilter = new InputFilter();
388
            $factory = new InputFactory();
389
390
            $inputFilter->add($factory->createInput(array(
391
                'name'       => 'id',
392
                'required'   => true,
393
                'filters' => array(
394
                    array('name'    => 'Int'),
395
                ),
396
            )));
397
398
            $inputFilter->add($factory->createInput(array(
399
                'name'     => 'answer',
400
                'required' => true,
401
            )));
402
403
            $inputFilter->add($factory->createInput(array(
404
                'name'     => 'position',
405
                'required' => true,
406
            )));
407
408
            $inputFilter->add($factory->createInput(array(
409
                'name'     => 'explanation',
410
                'required' => false,
411
            )));
412
413
            $inputFilter->add($factory->createInput(array(
414
                'name'     => 'correct',
415
                'required' => true,
416
                'validators' => array(
417
                    array(
418
                        'name'    => 'Between',
419
                        'options' => array(
420
                            'min'      => 0,
421
                            'max'      => 1,
422
                        ),
423
                    ),
424
                ),
425
            )));
426
427
            $inputFilter->add($factory->createInput(array(
428
                    'name'     => 'video',
429
                    'required' => false,
430
            )));
431
432
            $inputFilter->add($factory->createInput(array(
433
                'name'     => 'image',
434
                'required' => false,
435
            )));
436
437
            $inputFilter->add($factory->createInput(array(
438
                'name'     => 'jsonData',
439
                'required' => false,
440
                'allowEmpty' => true,
441
            )));
442
443
            $this->inputFilter = $inputFilter;
444
        }
445
446
        return $this->inputFilter;
447
    }
448
}
449