1 | <?php |
||||||
2 | /** |
||||||
3 | * Delete data |
||||||
4 | * User: moyo |
||||||
5 | * Date: 25/12/2017 |
||||||
6 | * Time: 3:27 PM |
||||||
7 | */ |
||||||
8 | |||||||
9 | namespace Carno\Database\SQL\Actions; |
||||||
10 | |||||||
11 | use Carno\Database\Results\Updated; |
||||||
12 | use Carno\Database\SQL\Action; |
||||||
13 | |||||||
14 | trait Delete |
||||||
15 | { |
||||||
16 | /** |
||||||
17 | * @param array ...$conditions |
||||||
18 | * @return int |
||||||
19 | */ |
||||||
20 | public function delete(...$conditions) |
||||||
21 | { |
||||||
22 | $this->actTrigger(Action::DELETE, $this); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
23 | |||||||
24 | $conditions && $this->where(...$conditions); |
||||||
0 ignored issues
–
show
The expression
$conditions of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() It seems like
where() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
25 | |||||||
26 | /** |
||||||
27 | * @var Updated $result |
||||||
28 | */ |
||||||
29 | $result = yield $this->exec($this->sql(Action::DELETE)); |
||||||
0 ignored issues
–
show
It seems like
sql() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() It seems like
exec() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
30 | |||||||
31 | return $result->rows(); |
||||||
32 | } |
||||||
33 | } |
||||||
34 |