@@ -103,7 +103,6 @@ public function setFile(string $file): self
103103
104104 /**
105105 * Set dir path to index files
106- * @param string $type Template type (index/partial/view)
107106 * @param string $dir Dir path
108107 * @return self
109108 */
@@ -116,7 +115,6 @@ public function setIndexDir(string $dir): self
116115
117116 /**
118117 * Set dir path to view files
119- * @param string $type Template type (index/partial/view)
120118 * @param string $dir Dir path
121119 * @return self
122120 */
@@ -141,7 +139,6 @@ public function setBufferDir(string $dir): self
141139
142140 /**
143141 * Set dir path to partial files
144- * @param string $type Template type (index/partial/view)
145142 * @param string $dir Dir path
146143 * @return self
147144 */
@@ -216,11 +213,10 @@ public function withView(string $file, array $args = array()): self
216213 */
217214 public function setPartial (string $ keyA , string |array $ keyB = array (), array $ keyC = array ()): self
218215 {
216+ $ partial = $ keyB ;
219217 if (is_array ($ keyB )) {
220218 $ keyC = $ keyB ;
221219 $ partial = $ keyA ;
222- } else {
223- $ partial = $ keyB ;
224220 }
225221
226222 if (is_null ($ this ->file )) {
@@ -293,7 +289,6 @@ public function index(?array $args = null): self
293289
294290 /**
295291 * Prepare buffer for return
296- * @param boolean $args Overwrite arguments
297292 * @return self
298293 */
299294 public function buffer (): self
@@ -305,7 +300,7 @@ public function buffer(): self
305300 /**
306301 * Prepare view for return
307302 * @param array|null $args Overwrite arguments
308- * @return slef
303+ * @return self
309304 */
310305 public function view (?array $ args = null ): self
311306 {
@@ -370,13 +365,13 @@ final public function get(?array $args = null): string
370365 private function buildView (): void
371366 {
372367 if (!is_null ($ this ->bindView )) {
373- if (( $ hasBuffer = $ this ->existAtGet ("buffer " )) || ( $ hasIndex = $ this -> existAtGet ( " index " ))) {
374- if ( $ hasBuffer ) {
375- $ this -> buffer = $ this -> bindView ;
376- }
377- if ( $ hasIndex ) {
378- $ this -> view = $ this -> bindView ;
379- }
368+ $ hasBuffer = $ this ->existAtGet ("buffer " );
369+ $ hasIndex = $ this -> existAtGet ( " index " );
370+ if ( $ hasBuffer ) {
371+ $ this -> buffer = $ this -> bindView ;
372+ }
373+ if ( $ hasIndex ) {
374+ $ this -> view = $ this -> bindView ;
380375 }
381376 }
382377 }
@@ -407,8 +402,7 @@ private function build(string|callable $file, array $args = array()): callable
407402 if (is_array ($ argsFromFile ) && count ($ argsFromFile ) > 0 ) {
408403 $ args = $ argsFromFile ;
409404 }
410- $ obj = Traverse::value ($ args );
411- include ($ filePath );
405+ $ this ->inclRouterFileData ($ filePath , Traverse::value ($ args ), $ args );
412406 } else {
413407 throw new Exception ("Could not require template file add {$ this ->get }: {$ dir }{$ file }. " , 1 );
414408 }
@@ -453,6 +447,19 @@ private function existAtGet(string $key): bool
453447 return (bool )(isset ($ this ->{$ key }) && $ this ->get === $ key );
454448 }
455449
450+ /**
451+ * Include router file with router object data
452+ * @param string $filePath
453+ * @param object $obj
454+ * @param array $args
455+ * @psalm-suppress UnusedParam
456+ * @return void
457+ */
458+ private function inclRouterFileData (string $ filePath , object $ obj , array $ args ): void
459+ {
460+ include ($ filePath );
461+ }
462+
456463 public function dom (string $ key ): Document
457464 {
458465 return Document::dom ($ key );
@@ -473,26 +480,4 @@ public function isEl($elem): bool
473480 {
474481 return (bool )($ elem instanceof Element);
475482 }
476-
477- /*
478- function dom(string $key): Document
479- {
480- return Document::dom($key);
481- }
482- function createTag(string $element, string $value, ?array $attr = NULL) {
483- $inst = new Document();
484- $el = $inst->create($element, $value)->attrArr($attr);
485- return $el;
486- }
487-
488- function isDoc($el): bool
489- {
490- return (bool)($el instanceof Document || $el instanceof Element);
491- }
492-
493- function isEl($el): bool
494- {
495- return (bool)($el instanceof Element);
496- }
497- */
498483}
0 commit comments