This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * To change this license header, choose License Headers in Project Properties. |
||
4 | * To change this template file, choose Tools | Templates |
||
5 | * and open the template in the editor. |
||
6 | */ |
||
7 | |||
8 | namespace SimpleORM; |
||
9 | |||
10 | /** |
||
11 | * Description of TraitDataMapperEvent |
||
12 | * |
||
13 | * @author d.lanec |
||
14 | */ |
||
15 | trait TraitDataMapperEvent { |
||
16 | |||
17 | /** |
||
18 | * Перед сохранением извелкаем объект и дополняем массив для записи, недостающими полями |
||
19 | * @param \Autoprice\Domain\Price\EntityInterface $Entity |
||
20 | * @param type $data |
||
21 | */ |
||
22 | protected function onPrepareData(\SimpleORM\EntityInterface $Entity, &$data) { |
||
0 ignored issues
–
show
|
|||
23 | foreach ($this->mapping_fields as $field => $cfg) { |
||
0 ignored issues
–
show
The property
mapping_fields 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;
![]() |
|||
24 | if (isset($cfg['null']) && $cfg['null'] === false && empty($data[$cfg['field']])) { |
||
25 | $data[$cfg['field']] = $cfg['default']; |
||
26 | } |
||
27 | } |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * На успешное удаление |
||
32 | * @param \SimpleORM\EntityInterface $Entity |
||
33 | */ |
||
34 | protected function onBeforeDelete(EntityInterface $Entity) { |
||
35 | foreach ($this->relations as $alias => $cfg) { |
||
0 ignored issues
–
show
The property
relations 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;
![]() |
|||
36 | $mapper = $cfg['mapper']; |
||
37 | //если связь один к одному то удаляем сущность |
||
38 | if ($cfg['reltype'] == 'has_one') { |
||
39 | $Entity = $Entity->{'get' . $alias}(); |
||
40 | if (!$mapper->delete($Entity)) { |
||
41 | throw new \Autoprice\Exceptions\EntityNotDeleteException('Unable to delete Entity!'); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | return true; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Событие перед сохранением |
||
51 | * @param \SimpleORM\EntityInterface $Entity |
||
52 | */ |
||
53 | protected function onAfterSave(EntityInterface $Entity) { |
||
54 | |||
55 | $this->getAdapter()->startTransaction(); |
||
0 ignored issues
–
show
It seems like
getAdapter() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
56 | |||
57 | $rel_list = $this->createListRelation(); |
||
0 ignored issues
–
show
It seems like
createListRelation() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
58 | |||
59 | foreach ($rel_list as $obj_path => $mapper) { |
||
60 | |||
61 | $call_obj = '$Entity'.$obj_path.';'; |
||
62 | |||
63 | $set_path = str_replace(['#', '();'], ['->set', '($o);'], $call_obj); |
||
64 | |||
65 | $ar_path = explode('()',$obj_path); |
||
66 | |||
67 | $o = $Entity; |
||
68 | |||
69 | foreach ($ar_path as $_m){ |
||
70 | |||
71 | $_mc = str_replace('#','get',ucfirst($_m)); |
||
72 | |||
73 | //Set logic |
||
74 | if(empty($_m)){ |
||
75 | |||
76 | $_mc = ltrim( $ar_path[(count($ar_path)-2)] , '#'); |
||
77 | |||
78 | if (isset($$_mc) && is_object($$_mc) && is_a($$_mc,'SimpleORM\EntityInterface') && $this->DI->get($mapper)->saveWithoutEvents($o)) { |
||
0 ignored issues
–
show
The property
DI 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;
![]() |
|||
79 | $o = $$_mc; |
||
80 | eval($set_path); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
81 | } |
||
82 | } |
||
83 | elseif(is_object($o) ){ |
||
84 | $$_mc = $o->{$_mc}(); |
||
85 | $o = $$_mc; |
||
86 | } |
||
87 | |||
88 | } |
||
89 | |||
90 | } |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * После успешного сохранения |
||
95 | * @param \SimpleORM\EntityInterface $Entity |
||
96 | */ |
||
97 | protected function onBeforeSave(EntityInterface $Entity) { |
||
0 ignored issues
–
show
|
|||
98 | |||
99 | $this->getAdapter()->endTransaction(); |
||
0 ignored issues
–
show
It seems like
getAdapter() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
100 | |||
101 | // foreach ($this->relations as $alias => $mapper) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
57% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
102 | // |
||
103 | // $SaveEntity = $Entity->{'get'.$alias}(); |
||
104 | // |
||
105 | // if(!$mapper->save($SaveEntity)){ |
||
106 | // throw new \Autoprice\Exceptions\EntityNotSaveException('Unable to save Entity!'); |
||
107 | // } |
||
108 | // |
||
109 | // unset($SaveEntity); |
||
110 | // } |
||
111 | // |
||
112 | // return true; |
||
113 | } |
||
114 | |||
115 | } |
||
116 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.