if_branch instanceof IF_Branch ) { $this->print_branch( 'if', $this->if_branch ); } foreach ( $this->elseif_branches as $elseif_branch ) { $this->print_branch( 'elseif', $elseif_branch ); } if ( $this->else_branch instanceof IF_Branch ) { $this->print_branch( 'else', $this->else_branch ); } $this->print_branch_token( 'endif' ); } protected function print_branch( string $type, IF_Branch $branch ): void { $this->print_branch_token( $type ); if ( $branch->condition instanceof Template_Token ) { echo ' ('; $branch->condition->print(); echo ')'; } if ( $branch->body instanceof Template_Token ) { $branch->body->print(); } } protected function print_branch_token( string $type ): void { printf( '@%s', esc_html( $type ) ); } }