Skip to content

Commit c87578f

Browse files
authored
Merge pull request #152 from yajra/view-string-null
fix(phpstan): Allow null on view
2 parents 28c269e + 0637266 commit c87578f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Services/DataTable.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ public function __construct()
193193
/**
194194
* Process dataTables needed render output.
195195
*
196-
* @phpstan-param view-string $view
196+
* @phpstan-param view-string|null $view
197197
*
198-
* @param string $view
198+
* @param string|null $view
199199
* @param array $data
200200
* @param array $mergeData
201201
* @return mixed
202202
*/
203-
public function render(string $view, array $data = [], array $mergeData = [])
203+
public function render(string $view = null, array $data = [], array $mergeData = [])
204204
{
205205
if ($this->request()->ajax() && $this->request()->wantsJson()) {
206206
return app()->call([$this, 'ajax']);
@@ -209,13 +209,15 @@ public function render(string $view, array $data = [], array $mergeData = [])
209209
/** @var string $action */
210210
$action = $this->request()->get('action');
211211

212-
if (in_array($action, $this->actions)) {
213-
if ($action == 'print') {
214-
return app()->call([$this, 'printPreview']);
215-
}
212+
if ($action == 'print') {
213+
$action = 'printPreview';
214+
}
216215

217-
// @phpstan-ignore-next-line
218-
return app()->call([$this, $action]);
216+
if (in_array($action, $this->actions) && method_exists($this, $action)) {
217+
/** @var callable $callback */
218+
$callback = [$this, $action];
219+
220+
return app()->call($callback);
219221
}
220222

221223
return view($view, $data, $mergeData)->with($this->dataTableVariable, $this->getHtmlBuilder());

0 commit comments

Comments
 (0)