Skip to content

Commit ca69abf

Browse files
authored
fix: argument type is error
1 parent 572fd7e commit ca69abf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/ViewRenderer.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ class ViewRenderer
2525
private $currentDir = '';
2626

2727
/** @var string Views file path. */
28-
protected $viewsPath = '';
28+
protected $viewsPath;
2929

30-
/** @var null|string Default layout file. */
31-
protected $layout = '';
30+
/** @var string Default layout file. */
31+
protected $layout;
3232

3333
/** @var array Attributes for the view */
3434
protected $attributes = [];
@@ -54,12 +54,12 @@ class ViewRenderer
5454
* @param string $layout
5555
* @param array $attributes
5656
*/
57-
public function __construct(string $viewsPath = null, string $layout = null, array $attributes = [])
57+
public function __construct(string $viewsPath = '', string $layout = '', array $attributes = [])
5858
{
5959
$this->layout = $layout;
6060
$this->attributes = $attributes;
6161

62-
$this->setViewsPath($this->viewsPath);
62+
$this->setViewsPath($viewsPath);
6363
}
6464

6565
/********************************************************************************
@@ -71,12 +71,12 @@ public function __construct(string $viewsPath = null, string $layout = null, arr
7171
* throws RuntimeException if view file does not exist
7272
* @param string $view
7373
* @param array $data extract data to view, cannot contain view as a key
74-
* @param string|null|false $layout Override default layout file.
74+
* @param string|false $layout Override default layout file.
7575
* False - will disable use layout file
7676
* @return string
7777
* @throws \RuntimeException
7878
*/
79-
public function render(string $view, array $data = [], $layout = null): string
79+
public function render(string $view, array $data = [], $layout = ''): string
8080
{
8181
$output = $this->fetch($view, $data);
8282

@@ -120,11 +120,12 @@ public function renderBody(string $content, array $data = [], string $layout = '
120120
*/
121121
public function renderContent(string $content, array $data = [], string $layout = ''): string
122122
{
123+
$layout = $layout ?: $this->layout;
124+
123125
// render layout
124-
if ($layout = $layout ?: $this->layout) {
125-
$mark = $this->placeholder;
126+
if ($layout && $this->placeholder) {
126127
$main = $this->fetch($layout, $data);
127-
$content = (string)\str_replace($mark, $content, $main);
128+
$content = (string)\str_replace($this->placeholder, $content, $main);
128129
}
129130

130131
if ($this->minify) {

0 commit comments

Comments
 (0)