22
33namespace dokuwiki \TreeBuilder ;
44
5-
65use dokuwiki \test \mock \Doku_Renderer ;
76use dokuwiki \TreeBuilder \Node \AbstractNode ;
87use dokuwiki \TreeBuilder \Node \ExternalLink ;
@@ -145,7 +144,7 @@ public function getTop(): Top
145144 public function getAll (): array
146145 {
147146 if (!$ this ->generated ) throw new \RuntimeException ('need to call generate() first ' );
148- if (empty ( $ this ->nodes ) ) {
147+ if ($ this ->nodes === [] ) {
149148 $ this ->nodes = [];
150149 foreach ($ this ->top ->getDescendants () as $ node ) {
151150 $ this ->nodes [$ node ->getId ()] = $ node ;
@@ -163,9 +162,7 @@ public function getAll(): array
163162 public function getLeaves (): array
164163 {
165164 if (!$ this ->generated ) throw new \RuntimeException ('need to call generate() first ' );
166- return array_filter ($ this ->getAll (), function ($ page ) {
167- return !$ page ->getChildren ();
168- });
165+ return array_filter ($ this ->getAll (), fn ($ page ) => !$ page ->getChildren ());
169166 }
170167
171168 /**
@@ -176,9 +173,7 @@ public function getLeaves(): array
176173 public function getBranches (): array
177174 {
178175 if (!$ this ->generated ) throw new \RuntimeException ('need to call generate() first ' );
179- return array_filter ($ this ->getAll (), function ($ page ) {
180- return !!$ page ->getChildren ();
181- });
176+ return array_filter ($ this ->getAll (), fn ($ page ) => (bool ) $ page ->getChildren ());
182177 }
183178
184179 /**
@@ -218,7 +213,7 @@ public function render(Doku_Renderer $R, $top = null, $level = 1): void
218213 foreach ($ top ->getChildren () as $ node ) {
219214 $ R ->listitem_open (1 , $ node ->hasChildren ());
220215 $ R ->listcontent_open ();
221- if (is_a ( $ node, ExternalLink::class) ) {
216+ if ($ node instanceof ExternalLink) {
222217 $ R ->externallink ($ node ->getId (), $ node ->getTitle ());
223218 } else {
224219 $ R ->internallink ($ node ->getId (), $ node ->getTitle ());
@@ -261,6 +256,6 @@ protected function applyRecursionDecision(AbstractNode $node, int $depth): bool
261256 */
262257 public function __toString (): string
263258 {
264- return join ("\n" , $ this ->getAll ());
259+ return implode ("\n" , $ this ->getAll ());
265260 }
266261}
0 commit comments