namespace BookStack\Api;
-use BookStack\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListingResponseBuilder
{
- protected $query;
- protected $request;
- protected $fields;
+ protected Builder $query;
+ protected Request $request;
+
+ /**
+ * @var string[]
+ */
+ protected array $fields;
/**
* @var array<callable>
*/
- protected $resultModifiers = [];
+ protected array $resultModifiers = [];
- protected $filterOperators = [
+ /**
+ * @var array<string, string>
+ */
+ protected array $filterOperators = [
'eq' => '=',
'ne' => '!=',
'gt' => '>',
$filteredQuery = $this->filterQuery($this->query);
$total = $filteredQuery->count();
- $data = $this->fetchData($filteredQuery)->each(function($model) {
+ $data = $this->fetchData($filteredQuery)->each(function ($model) {
foreach ($this->resultModifiers as $modifier) {
$modifier($model);
}
}
/**
- * Add a callback to modify each element of the results
- * @param (callable(Model)) $modifier
+ * Add a callback to modify each element of the results.
+ *
+ * @param (callable(Model): void) $modifier
*/
- public function modifyResults($modifier): void
+ public function modifyResults(callable $modifier): void
{
$this->resultModifiers[] = $modifier;
}