When using PHP intelephense in VS Code for my laminas project, it is showing error,
Undefined method 'toArray'
My code looks as below,
<?php
namespace SomethingModel;
use LaminasDbAdapterAdapter;
use LaminasDbSqlSelect;
use InfrastructureAbstractionAbstractTableGateway;
class SomethingModel extends AbstractTableGateway
{
protected $table = 'some_table';
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
}
public function getSomething($arrTraitId)
{
return $this->select(function (Select $select) use () {
$select->columns(['something']);
})->toArray();
}
}
I was able eliminate this error by changing the code as follows,
/** @var LaminasDbResultSetAbstractResultSet $select **/
$select = $this->select(function (Select $select) use ($arrTraitId) {
$select->columns(['spirit_trial_id']);
$select->where(['spirit_trial_id' => $arrTraitId]);
});
return $select->toArray();
But i don’t want it to assign to any variable. So is there any alternative way to remove the error?