@@ -650,10 +650,15 @@ private function renderBranchStructure(FileNode $node): string
650650 continue ;
651651 }
652652
653- $ branches . = '<h5 class="structure-heading"><a name=" ' . htmlspecialchars ( $ methodName , $ this -> htmlSpecialCharsFlags ) . ' "> ' . $ this -> abbreviateMethodName ( $ methodName ) . ' </a></h5> ' . "\n" ;
653+ $ branchStructure = '' ;
654654
655655 foreach ($ methodData ['branches ' ] as $ branch ) {
656- $ branches .= $ this ->renderBranchLines ($ branch , $ codeLines , $ testData );
656+ $ branchStructure .= $ this ->renderBranchLines ($ branch , $ codeLines , $ testData );
657+ }
658+
659+ if ($ branchStructure !== '' ) { // don't show empty branches
660+ $ branches .= '<h5 class="structure-heading"><a name=" ' . htmlspecialchars ($ methodName , $ this ->htmlSpecialCharsFlags ) . '"> ' . $ this ->abbreviateMethodName ($ methodName ) . '</a></h5> ' . "\n" ;
661+ $ branches .= $ branchStructure ;
657662 }
658663 }
659664
@@ -720,6 +725,10 @@ private function renderBranchLines(array $branch, array $codeLines, array $testD
720725 $ lines .= $ this ->renderLine ($ singleLineTemplate , $ line , $ codeLines [$ line - 1 ], $ trClass , $ popover );
721726 }
722727
728+ if ($ lines === '' ) {
729+ return '' ;
730+ }
731+
723732 $ linesTemplate ->setVar (['lines ' => $ lines ]);
724733
725734 return $ linesTemplate ->render ();
@@ -741,16 +750,21 @@ private function renderPathStructure(FileNode $node): string
741750 continue ;
742751 }
743752
744- $ paths . = '<h5 class="structure-heading"><a name=" ' . htmlspecialchars ( $ methodName , $ this -> htmlSpecialCharsFlags ) . ' "> ' . $ this -> abbreviateMethodName ( $ methodName ) . ' </a></h5> ' . "\n" ;
753+ $ pathStructure = '' ;
745754
746755 if (count ($ methodData ['paths ' ]) > 100 ) {
747- $ paths .= '<p> ' . count ($ methodData ['paths ' ]) . ' is too many paths to sensibly render, consider refactoring your code to bring this number down.</p> ' ;
756+ $ pathStructure .= '<p> ' . count ($ methodData ['paths ' ]) . ' is too many paths to sensibly render, consider refactoring your code to bring this number down.</p> ' ;
748757
749758 continue ;
750759 }
751760
752761 foreach ($ methodData ['paths ' ] as $ path ) {
753- $ paths .= $ this ->renderPathLines ($ path , $ methodData ['branches ' ], $ codeLines , $ testData );
762+ $ pathStructure .= $ this ->renderPathLines ($ path , $ methodData ['branches ' ], $ codeLines , $ testData );
763+ }
764+
765+ if ($ pathStructure !== '' ) {
766+ $ paths .= '<h5 class="structure-heading"><a name=" ' . htmlspecialchars ($ methodName , $ this ->htmlSpecialCharsFlags ) . '"> ' . $ this ->abbreviateMethodName ($ methodName ) . '</a></h5> ' . "\n" ;
767+ $ paths .= $ pathStructure ;
754768 }
755769 }
756770
@@ -819,6 +833,10 @@ private function renderPathLines(array $path, array $branches, array $codeLines,
819833 }
820834 }
821835
836+ if ($ lines === '' ) {
837+ return '' ;
838+ }
839+
822840 $ linesTemplate ->setVar (['lines ' => $ lines ]);
823841
824842 return $ linesTemplate ->render ();
0 commit comments