Issues (59)

src/Actions/Update.php (6 issues)

1
<?php
2
/**
3
 * Update data
4
 * User: moyo
5
 * Date: 25/12/2017
6
 * Time: 3:24 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 Update
15
{
16
    /**
17
     * @param array ...$maps
18
     * @return int
19
     */
20
    public function update(...$maps)
21
    {
22
        $this->actTrigger(Action::UPDATE, $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::UPDATE, $this);
Loading history...
23
24
        $maps && $this->data(...$maps);
0 ignored issues
show
It seems like data() 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
        $maps && $this->/** @scrutinizer ignore-call */ data(...$maps);
Loading history...
Bug Best Practice introduced by
The expression $maps 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...
25
26
        /**
27
         * @var Updated $result
28
         */
29
        $result = yield $this->exec($this->sql(Action::UPDATE));
0 ignored issues
show
Bug Best Practice introduced by
The expression yield $this->exec($this-...se\SQL\Action::UPDATE)) returns the type Generator which is incompatible with the documented return type integer.
Loading history...
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::UPDATE));
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::UPDATE));
Loading history...
30
31
        return $result->rows();
32
    }
33
}
34