Issues (59)

src/Actions/Delete.php (6 issues)

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
It seems like actTrigger() 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 ignore-call  annotation

22
        $this->/** @scrutinizer ignore-call */ 
23
               actTrigger(Action::DELETE, $this);
Loading history...
23
24
        $conditions && $this->where(...$conditions);
0 ignored issues
show
Bug Best Practice introduced by
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 empty(..) or ! empty(...) instead.

Loading history...
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 ignore-call  annotation

24
        $conditions && $this->/** @scrutinizer ignore-call */ where(...$conditions);
Loading history...
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 ignore-call  annotation

29
        $result = yield $this->exec($this->/** @scrutinizer ignore-call */ sql(Action::DELETE));
Loading history...
Bug Best Practice introduced by
The expression yield $this->exec($this-...se\SQL\Action::DELETE)) returns the type Generator which is incompatible with the documented return type integer.
Loading history...
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 ignore-call  annotation

29
        $result = yield $this->/** @scrutinizer ignore-call */ exec($this->sql(Action::DELETE));
Loading history...
30
31
        return $result->rows();
32
    }
33
}
34