for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Staudenmeir\LaravelUpsert\Query\Grammars;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Grammars\MySqlGrammar as Base;
use Illuminate\Support\Str;
class MySqlGrammar extends Base
{
use CompilesUpsertQueries;
/**
* Compile an "upsert" statement into SQL.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $values
* @param array $target
* @param array $update
* @return string
*/
public function compileUpsert(Builder $query, array $values, array $target, array $update)
$target
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function compileUpsert(Builder $query, array $values, /** @scrutinizer ignore-unused */ array $target, array $update)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$sql = $this->compileInsert($query, $values).' on duplicate key update ';
$columns = collect($update)->map(function ($value, $key) {
return is_numeric($key)
? $this->wrap($value).' = values('.$this->wrap($value).')'
: $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
return $sql.$columns;
}
* Compile an "insert ignore" statement into SQL.
public function compileInsertIgnore(Builder $query, array $values, array $target)
public function compileInsertIgnore(Builder $query, array $values, /** @scrutinizer ignore-unused */ array $target)
$sql = $this->compileInsert($query, $values);
return Str::replaceFirst('insert', 'insert ignore', $sql);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.