Description
Phalcon\Mvc\Model::groupResult() is declared with the return type Phalcon\Mvc\Model\ResultsetInterface, but it can return scalar values when used by aggregate methods such as count(), sum(), average(), maximum(), and minimum().
This causes issues when extending Phalcon\Mvc\Model. Any overriding implementation must declare a compatible return type (ResultsetInterface), but the parent method may actually return scalar values. As a result, custom model classes cannot safely override groupResult() without risking runtime TypeError exceptions.
TypeError: Return value must be of type Phalcon\Mvc\Model\ResultsetInterface, int returned
Current signature
protected static function groupResult(
string $functionName,
string $alias,
$parameters = null
): ResultsetInterface
Problem
The implementation returns the resultset when a group clause is present, but otherwise returns the aggregate value from the first row:
return $firstRow->{$alias};
This value is typically an int, float, or string, not a ResultsetInterface.
Description
Phalcon\Mvc\Model::groupResult()is declared with the return typePhalcon\Mvc\Model\ResultsetInterface, but it can return scalar values when used by aggregate methods such ascount(),sum(),average(),maximum(), andminimum().This causes issues when extending Phalcon\Mvc\Model. Any overriding implementation must declare a compatible return type (ResultsetInterface), but the parent method may actually return scalar values. As a result, custom model classes cannot safely override groupResult() without risking runtime TypeError exceptions.
Current signature
Problem
The implementation returns the resultset when a
groupclause is present, but otherwise returns the aggregate value from the first row:This value is typically an
int,float, orstring, not aResultsetInterface.