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 | namespace PhpBoot\ORM; |
||
3 | |||
4 | use Doctrine\Common\Cache\Cache; |
||
5 | use PhpBoot\DB\DB; |
||
6 | |||
7 | class ModelWithClass |
||
8 | { |
||
9 | /** |
||
10 | * Model constructor. |
||
11 | * @param DB $db |
||
12 | * @param string $entityName |
||
13 | * @param Cache $cache |
||
14 | */ |
||
15 | 7 | public function __construct(DB $db, $entityName, Cache $cache) |
|
0 ignored issues
–
show
|
|||
16 | { |
||
17 | 7 | $this->db = $db; |
|
18 | 7 | $builder = $db->getApp()->get(ModelContainerBuilder::class); |
|
19 | 7 | $this->entity = $builder->build($entityName); |
|
20 | 7 | } |
|
21 | |||
22 | /** |
||
23 | * @param string $id |
||
24 | * @return mixed|null |
||
25 | */ |
||
26 | 1 | public function find($id) |
|
27 | { |
||
28 | 1 | $row = $this->db->select($this->getColumns()) |
|
0 ignored issues
–
show
Are you sure the assignment to
$row is correct as $this->db->select($this-... = ?", $id)->getFirst() (which targets PhpBoot\DB\rules\select\GetRule::getFirst() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
29 | 1 | ->from($this->entity->getTable()) |
|
30 | 1 | ->where("`{$this->entity->getPK()}` = ?", $id) |
|
31 | 1 | ->getFirst(); |
|
32 | 1 | if($row){ |
|
33 | return $this->entity->make($row, false); |
||
34 | }else{ |
||
35 | 1 | return null; |
|
36 | } |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return int rows deleted |
||
41 | */ |
||
42 | 1 | public function delete($id) |
|
43 | { |
||
44 | 1 | return $this->db->deleteFrom($this->entity->getTable()) |
|
45 | 1 | ->where([$this->entity->getPK()=>$id]) |
|
46 | 1 | ->limit(1) |
|
47 | 1 | ->exec()->rows; |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * where 语法见 @see WhereRule |
||
52 | * @param array|string $expr |
||
0 ignored issues
–
show
There is no parameter named
$expr . 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 /**
* @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. ![]() |
|||
53 | * @param mixed|null $_ |
||
54 | * @return \PhpBoot\DB\rules\basic\WhereRule |
||
55 | */ |
||
56 | 1 | public function deleteWhere($conditions, $_=null) |
|
0 ignored issues
–
show
|
|||
57 | { |
||
58 | 1 | $query = $this->db->deleteFrom($this->entity->getTable()); |
|
59 | 1 | return call_user_func_array([$query, 'where'], func_get_args()); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return false|int |
||
64 | */ |
||
65 | public function count() |
||
66 | { |
||
67 | return $this->db->select($this->getColumns()) |
||
68 | ->from($this->entity->getTable()) |
||
69 | ->count(); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * where 语法见 @see WhereRule |
||
74 | * @param array|string|callable|null $conditions |
||
75 | * @param string $_ |
||
76 | * @return \PhpBoot\DB\rules\select\WhereRule |
||
77 | */ |
||
78 | 2 | public function findWhere($conditions=null, $_=null) |
|
0 ignored issues
–
show
|
|||
79 | { |
||
80 | 2 | $query = $this->db->select($this->getColumns()) |
|
81 | 2 | ->from($this->entity->getTable()); |
|
82 | $query->context->resultHandler = function ($result){ |
||
83 | foreach ($result as &$i){ |
||
84 | $i = $this->entity->make($i, false); |
||
85 | } |
||
86 | return $result; |
||
87 | }; |
||
88 | 2 | return call_user_func_array([$query, 'where'], func_get_args()); |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * @param int|string $id |
||
93 | * @param array $values |
||
94 | * @return int updated row count |
||
95 | */ |
||
96 | 1 | public function update($id, $values) |
|
97 | { |
||
98 | 1 | return $this->db->update($this->entity->getTable()) |
|
99 | 1 | ->set($values) |
|
100 | 1 | ->where([$this->entity->getPK()=>$id]) |
|
101 | 1 | ->exec(); |
|
102 | } |
||
103 | |||
104 | /** |
||
105 | * @param array $values |
||
106 | * @param array|string|callable $conditions where 语法见 @see WhereRule |
||
107 | * @param string $_ |
||
108 | * @return \PhpBoot\DB\rules\basic\WhereRule |
||
109 | */ |
||
110 | 1 | public function updateWhere($values, $conditions, $_=null) |
|
0 ignored issues
–
show
|
|||
111 | { |
||
112 | 1 | $query = $this->db->update($this->entity->getTable())->set($values); |
|
113 | 1 | return call_user_func_array([$query, 'where'], array_slice(func_get_args(),1)); |
|
114 | } |
||
115 | |||
116 | /** |
||
117 | * set entity table name |
||
118 | * @param string $tableName |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function withTable($tableName) |
||
122 | { |
||
123 | $this->entity->setTable($tableName); |
||
124 | return $this; |
||
125 | } |
||
126 | |||
127 | 3 | protected function getColumns() |
|
128 | { |
||
129 | 3 | $columns = []; |
|
130 | 3 | foreach ($this->entity->getProperties() as $p){ |
|
131 | 3 | $columns[] = $p->name; |
|
132 | 3 | } |
|
133 | 3 | return $columns; |
|
134 | } |
||
135 | /** |
||
136 | * @var ModelContainer |
||
137 | */ |
||
138 | protected $entity; |
||
139 | /** |
||
140 | * @var DB |
||
141 | */ |
||
142 | protected $db; |
||
143 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.