laminas/laminas-db

PSALM issues. (Doc blocks use Expression instead of PredicateInterface)

zagovorichev opened this issue · 1 comments

Bug Report

Doc blocks use Expression instead of PredicateInterface

Q A
Version(s) from 2.11 (and earlier I guess)

Summary

I can pass Literal to Predicate:

$select->where
                ->equalTo(
                    'something.Status',
                    new Literal(':status'),
                    Where::TYPE_IDENTIFIER,
                    Where::TYPE_VALUE
                );

but method expects Expression only, so psalm told me that I'm using the wrong class (probably @param int|float|bool|string|Expression $right should be changed to using of interface? PredicateInterface)

/**
     * Create "Equal To" predicate
     *
     * Utilizes Operator predicate
     *
     * @param  int|float|bool|string|Expression $left
     * @param  int|float|bool|string|Expression $right
     * @param  string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
     * @param  string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
     * @return self Provides a fluent interface
     */
    public function equalTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
    {
        $this->addPredicate(
            new Operator($left, Operator::OPERATOR_EQUAL_TO, $right, $leftType, $rightType),
            $this->nextPredicateCombineOperator ?: $this->defaultCombination
        );
        $this->nextPredicateCombineOperator = null;

        return $this;
    }

Current behavior

PSALM shows an error

How to reproduce

Run Psalm

Expected behavior

Psalm doesn't show any errors

I am just curious does it work when you pass literal?)