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 declare(strict_types = 1); |
||
2 | namespace samson\activerecord; |
||
3 | |||
4 | use samsonframework\orm\ArgumentInterface; |
||
5 | use samsonframework\orm\Condition; |
||
6 | use samsonframework\orm\ConditionInterface; |
||
7 | use samsonframework\orm\QueryHandler; |
||
8 | use samsonframework\orm\QueryInterface; |
||
9 | |||
10 | /** |
||
11 | * This class will be removed in next major release. |
||
12 | * @author Vitaly Iegorov <[email protected]> |
||
13 | * @deprecated Should be removed ASAP in favor of generated classes or DI |
||
14 | * |
||
15 | */ |
||
16 | class dbQuery extends QueryHandler |
||
0 ignored issues
–
show
|
|||
17 | { |
||
18 | /** Virtual field for base table */ |
||
19 | public $own_virtual_fields = array(); |
||
20 | /** Virtual fields */ |
||
21 | public $virtual_fields = array(); |
||
22 | public $empty = false; |
||
23 | protected $class_name; |
||
24 | /** |
||
25 | * @var QueryInterface |
||
26 | */ |
||
27 | protected $query; |
||
28 | /** @var bool True to show requests */ |
||
29 | protected $debug = false; |
||
30 | |||
31 | /** Constructor */ |
||
32 | public function __construct() |
||
33 | { |
||
34 | $this->database = $GLOBALS['__core']->getContainer()->getDatabase(); |
||
0 ignored issues
–
show
The property
database 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;
![]() |
|||
35 | $this->sqlBuilder = $GLOBALS['__core']->getContainer()->getSqlBuilder(); |
||
0 ignored issues
–
show
The property
sqlBuilder 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 | } |
||
37 | |||
38 | /** |
||
39 | * @param string $metadata |
||
40 | * |
||
41 | * @deprecated Use entity() |
||
42 | * @return QueryInterface|string |
||
43 | */ |
||
44 | public function className(string $metadata = null) |
||
45 | { |
||
46 | if (func_num_args() === 0) { |
||
47 | return $this->metadata->className; |
||
0 ignored issues
–
show
The property
metadata 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;
![]() |
|||
48 | } else { |
||
49 | return $this->entity($metadata); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
samson\activerecord\dbQuery as the method entity() does only exist in the following sub-classes of samson\activerecord\dbQuery : samsonframework\orm\Query . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
50 | } |
||
51 | } |
||
52 | |||
53 | |||
54 | /** @deprecated Use QueryInterface implementation */ |
||
55 | public function own_limit($st, $en = 0) |
||
0 ignored issues
–
show
|
|||
56 | { |
||
57 | $this->query->limit($st, $en); |
||
58 | |||
59 | return $this; |
||
60 | } |
||
61 | |||
62 | /** @deprecated Use QueryInterface implementation */ |
||
63 | public function own_group_by($params) |
||
0 ignored issues
–
show
|
|||
64 | { |
||
65 | $this->query->groupBy($this->class_name, $params); |
||
0 ignored issues
–
show
The call to
QueryInterface::groupBy() has too many arguments starting with $params .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
66 | |||
67 | return $this; |
||
68 | } |
||
69 | |||
70 | /** @deprecated Use QueryInterface implementation */ |
||
71 | public function own_order_by($field, $direction = 'ASC') |
||
0 ignored issues
–
show
|
|||
72 | { |
||
73 | $this->query->orderBy($this->class_name, $field, $direction); |
||
0 ignored issues
–
show
The call to
QueryInterface::orderBy() has too many arguments starting with $direction .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
74 | |||
75 | return $this; |
||
76 | } |
||
77 | |||
78 | /** @see idbQuery::random() */ |
||
79 | public function random(& $return_value = null) |
||
80 | { |
||
81 | // Add random ordering |
||
82 | $this->order_by('', 'RAND()'); |
||
0 ignored issues
–
show
The method
samson\activerecord\dbQuery::order_by() has been deprecated with message: Use groupBy()
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
83 | |||
84 | // Correctly perform db request for multiple data |
||
85 | return func_num_args() ? $this->exec($return_value) : $this->exec(); |
||
0 ignored issues
–
show
The call to
dbQuery::exec() has too many arguments starting with $return_value .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() The method
samson\activerecord\dbQuery::exec() has been deprecated with message: Use self::find()
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param $columnName |
||
90 | * @param string $sorting |
||
91 | * |
||
92 | * @deprecated Use groupBy() |
||
93 | * @return QueryInterface|static |
||
94 | */ |
||
95 | public function order_by($columnName, $sorting = 'ASC') |
||
0 ignored issues
–
show
|
|||
96 | { |
||
97 | return $this->orderBy($this->metadata->tableName, $columnName, $sorting); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
samson\activerecord\dbQuery as the method orderBy() does only exist in the following sub-classes of samson\activerecord\dbQuery : samsonframework\orm\Query . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Execute current query and receive collection of RecordInterface objects from database. |
||
102 | * @deprecated Use self::find() |
||
103 | * @return RecordInterface[] Database entities collection |
||
104 | */ |
||
105 | public function exec() : array |
||
106 | { |
||
107 | return $this->find(); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
samson\activerecord\dbQuery as the method find() does only exist in the following sub-classes of samson\activerecord\dbQuery : samsonframework\orm\Query . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
108 | } |
||
109 | |||
110 | /** @deprecated Use QueryInterface implementation */ |
||
111 | public function or_($relation = 'OR') |
||
0 ignored issues
–
show
|
|||
112 | { |
||
113 | // Получим либо переданную группу условий, либо создадим новую, потом добавим её в массив групп условий запроса |
||
114 | $cond_group = new Condition($relation); |
||
115 | |||
116 | // Установим текущую группу условий с которой работает запрос |
||
117 | $this->cConditionGroup = &$cond_group; |
||
0 ignored issues
–
show
The property
cConditionGroup 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;
![]() |
|||
118 | |||
119 | // Добавим нову группу условий в коллекцию групп |
||
120 | $this->condition->arguments[] = $cond_group; |
||
0 ignored issues
–
show
The property
condition does not seem to exist. Did you mean cConditionGroup ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
121 | |||
122 | // Вернем себя для цепирования |
||
123 | return $this; |
||
124 | } |
||
125 | |||
126 | /** @deprecated Use QueryInterface implementation */ |
||
127 | public function debug($value = true) |
||
128 | { |
||
129 | db()->debug($this->debug = $value); |
||
0 ignored issues
–
show
The function
db() has been deprecated with message: Use dependency injection or generated class
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
130 | |||
131 | return $this; |
||
132 | } |
||
133 | |||
134 | /** @deprecated Use QueryInterface implementation */ |
||
135 | public function fieldsNew($fieldName, & $return = null) |
||
0 ignored issues
–
show
|
|||
136 | { |
||
137 | return call_user_func_array(array($this, 'fields'), func_get_args()); |
||
138 | } |
||
139 | |||
140 | /** @deprecated Use QueryInterface implementation */ |
||
141 | public function group_by($field) |
||
0 ignored issues
–
show
|
|||
142 | { |
||
143 | $this->query->groupBy($this->metadata->tablename, $field); |
||
0 ignored issues
–
show
The call to
QueryInterface::groupBy() has too many arguments starting with $field .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
144 | |||
145 | // Вернем себя для цепирования |
||
146 | return $this; |
||
147 | } |
||
148 | |||
149 | /** @deprecated Use QueryInterface implementation */ |
||
150 | public function add_field($field, $alias = null, $own = true) |
||
0 ignored issues
–
show
|
|||
151 | { |
||
152 | // Если передан псевдоним для поля, то подставим его |
||
153 | if (isset($alias)) { |
||
154 | $field = $field . ' as ' . $alias; |
||
155 | } else { |
||
156 | $alias = $field; |
||
157 | } |
||
158 | |||
159 | // Добавим виртуальное поле |
||
160 | if ($own) { |
||
161 | $this->own_virtual_fields[$alias] = $field; |
||
162 | } else { |
||
163 | $this->virtual_fields[$alias] = $field; |
||
164 | } |
||
165 | |||
166 | // Вернем себя для цепирования |
||
167 | return $this; |
||
168 | } |
||
169 | |||
170 | /** @deprecated Use QueryInterface implementation */ |
||
171 | public function innerCount($field = '*') |
||
0 ignored issues
–
show
|
|||
172 | { |
||
173 | return $this->query->count(); |
||
174 | } |
||
175 | |||
176 | /** @deprecated Use QueryInterface implementation */ |
||
177 | public function id($value) |
||
178 | { |
||
179 | $this->query->primary($value); |
||
180 | |||
181 | return $this; |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * Add condition to current query. |
||
186 | * This method supports receives three possible types for $fieldName, |
||
187 | * this is deprecated logic and this should be changed to use separate methods |
||
188 | * for each argument type. |
||
189 | * |
||
190 | * @param string|ConditionInterface|ArgumentInterface $fieldName Entity field name |
||
191 | * @param string $fieldValue Value |
||
192 | * @param string $relation Relation between field name and its value |
||
193 | * |
||
194 | * @deprecated Use QueryInterface implementation |
||
195 | * @return self Chaining |
||
196 | */ |
||
197 | public function cond($fieldName, $fieldValue = null, $relation = '=') |
||
198 | { |
||
199 | // If empty array is passed |
||
200 | if (is_string($fieldName)) { |
||
201 | return $this->where($fieldName, $fieldValue, $relation); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
samson\activerecord\dbQuery as the method where() does only exist in the following sub-classes of samson\activerecord\dbQuery : samsonframework\orm\Query . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
202 | } elseif (is_array($fieldValue) && !sizeof($fieldValue)) { |
||
203 | $this->empty = true; |
||
204 | return $this; |
||
205 | } elseif ($fieldName instanceof ConditionInterface) { |
||
206 | $this->whereCondition($fieldName); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
samson\activerecord\dbQuery as the method whereCondition() does only exist in the following sub-classes of samson\activerecord\dbQuery : samsonframework\orm\Query . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
207 | } elseif ($fieldName instanceof ArgumentInterface) { |
||
208 | $this->whereCondition((new Condition())->addArgument($fieldName)); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
samson\activerecord\dbQuery as the method whereCondition() does only exist in the following sub-classes of samson\activerecord\dbQuery : samsonframework\orm\Query . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
209 | } |
||
210 | |||
211 | return $this; |
||
212 | } |
||
213 | } |
||
214 |
Classes in PHP are usually named in CamelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes
DatabaseProvider
.