Issues (59)

src/Actions/Insert.php (6 issues)

1
<?php
2
/**
3
 * Insert data
4
 * User: moyo
5
 * Date: 25/12/2017
6
 * Time: 3:11 PM
7
 */
8
9
namespace Carno\Database\SQL\Actions;
10
11
use Carno\Database\Results\Created;
12
use Carno\Database\SQL\Action;
13
14
trait Insert
15
{
16
    /**
17
     * @param array ...$maps
18
     * @return int
19
     */
20
    public function insert(...$maps)
21
    {
22
        $this->actTrigger(Action::INSERT, $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::INSERT, $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 Created $result
28
         */
29
        return
30
            ($result = yield $this->exec($this->sql(Action::INSERT))) instanceof Created
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

30
            ($result = yield $this->exec($this->/** @scrutinizer ignore-call */ sql(Action::INSERT))) instanceof Created
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

30
            ($result = yield $this->/** @scrutinizer ignore-call */ exec($this->sql(Action::INSERT))) instanceof Created
Loading history...
Bug Best Practice introduced by
The expression yield $this->exec($this-...se\SQL\Action::INSERT)) returns the type Generator which is incompatible with the documented return type integer.
Loading history...
31
                ? $result->id()
32
                : 0
33
        ;
34
    }
35
}
36