auraphp/Aura.SqlQuery

PHPStan issue with where() method

odan opened this issue · 3 comments

odan commented

Hi!

I have an issue with PHPStan in combination with the where method and the variable-length argument lists.

Example code:

$query = new QueryFactory('mysql');
$select = $query->newSelect();
$select->cols(['*'])->from('users')->where('id = ?', 1);

PHPStan output:

[exec]   118    Method Aura\SqlQuery\Common\WhereInterface::where() invoked with 2
[exec]          parameters, 1 required.

The same issue with scrutinizer-ci:

$update->where("$key = ?", $value);
> Unused Code: The call to UpdateInterface::where() has too many arguments starting with $value.

$delete->where("$key = ?", $value);
> Unused Code: The call to DeleteInterface::where() has too many arguments starting with $value.

The current signature of the where method in the WhereInterface is defined like this:

interface WhereInterface
{
    public function where($cond);

PHP has support for variable-length argument lists in user-defined functions. This is implemented using the ... token in PHP 5.6 and later.

Possible fix:

interface WhereInterface
{
    public function where(...$cond);
  1. Question: Would it be possible to update the required PHP version from 5.3.9 to 5.6 (or better 7.x)?
  2. Question: Would it be possible to add the ... token to all where methods?

Sorry that the issue was missed by me.

Regarding your questions : All are BC breaks. Also there will be no longer another version of this library. Please see https://github.com/atlasphp or newer versions, if you are interested.

odan commented

Okay, good to know. You should let others know that this library is no longer actively maintained.

https://help.github.com/articles/archiving-repositories/

@odan The library is maintained, but we cannot make BC breaks without releasing a major version. Your issue might better be targeted against the 3.x branch.