@@ -77,6 +77,16 @@ public function setContainer(ContainerInterface $container): void
7777 $ this ->container = $ container ;
7878 }
7979
80+ /**
81+ * Set a PSR-6 cache instance for partial views, not required
82+ * @param CacheInterface $cache
83+ * @return void
84+ */
85+ public function setCache (CacheInterface $ cache ): void
86+ {
87+ $ this ->cache = $ cache ;
88+ }
89+
8090 /**
8191 * Get container instance
8292 * @return ContainerInterface
@@ -202,7 +212,7 @@ public function setBuffer(string $output): self
202212 * @return self
203213 * @throws Exception
204214 */
205- public function setView (string |callable $ file , array $ args = array () ): self
215+ public function setView (string |callable $ file , array $ args = [] ): self
206216 {
207217 if (is_null ($ this ->file ) && is_string ($ file )) {
208218 $ this ->setFile ($ file );
@@ -219,7 +229,7 @@ public function setView(string|callable $file, array $args = array()): self
219229 * @return self
220230 * @throws Exception
221231 */
222- public function withView (string $ file , array $ args = array () ): self
232+ public function withView (string $ file , array $ args = [] ): self
223233 {
224234 $ inst = clone $ this ;
225235 $ inst ->setView ($ file , $ args );
@@ -234,9 +244,8 @@ public function withView(string $file, array $args = array()): self
234244 * @return SwiftRender
235245 * @throws Exception
236246 */
237- public function setPartial (string $ partial , array $ args = array () , int |false $ cacheTime = false ): self
247+ public function setPartial (string $ partial , array $ args = [] , int |false $ cacheTime = false ): self
238248 {
239- $ this ->partialKey = $ partial ;
240249 $ keys = $ this ->selectPartial ($ partial , $ file );
241250 if (is_null ($ this ->file )) {
242251 $ this ->setFile ($ file );
@@ -273,7 +282,7 @@ public function unsetPartial(string $key): void
273282 * @return self
274283 * @throws Exception
275284 */
276- public function bindToBody (string $ key , array $ bindArr , array $ args = array () ): self
285+ public function bindToBody (string $ key , array $ bindArr , array $ args = [] ): self
277286 {
278287 $ this ->setFile ($ key );
279288 $ func = $ this ->build ($ this ->file , $ args );
@@ -413,11 +422,10 @@ private function buildView(): void
413422 */
414423 private function build (
415424 string |callable $ file ,
416- array $ args = array () ,
425+ array $ args = [] ,
417426 ?string $ partialKey = null ,
418427 int |false $ cacheTime = false
419- ): callable
420- {
428+ ): callable {
421429
422430 if (is_null ($ this ->cache ) && $ cacheTime !== false ) {
423431 throw new Exception ("Cache is not configured " );
@@ -433,7 +441,7 @@ private function build(
433441 } else {
434442
435443 $ throwError = true ;
436- $ missingFiles = array () ;
444+ $ missingFiles = [] ;
437445 $ files = explode ("| " , $ file );
438446
439447 foreach ($ files as $ file ) {
@@ -484,8 +492,7 @@ private function getOutput(
484492 ?string $ partialKey = null ,
485493 array $ args = [],
486494 int |false $ cacheTime = false
487- ): void
488- {
495+ ): void {
489496 if ($ this ->get == "partial " && !is_null ($ this ->cache ) && $ cacheTime !== false ) {
490497 $ partialKey = str_replace (["! " , "/ " ], ["" , "_ " ], $ partialKey );
491498 $ updateTime = filemtime ($ filePath );
@@ -552,7 +559,7 @@ private function existAtGet(string $key): bool
552559 */
553560 private function inclRouterFileData (string $ filePath , object $ obj , array $ args ): void
554561 {
555- $ extract = ($ obj instanceof Traverse) ? $ obj ->toArray (function ($ row ) {
562+ $ extract = ($ obj instanceof Traverse) ? $ obj ->toArray (function ($ row ) {
556563 return Traverse::value ($ row );
557564 }) : $ args ;
558565 extract ($ extract );
0 commit comments