@@ -89,7 +89,7 @@ public function attributes(array $attributes): string
89
89
}
90
90
}
91
91
92
- return count ($ html ) > 0 ? ' ' .implode (' ' , $ html ) : '' ;
92
+ return ! empty ($ html ) ? ' ' .implode (' ' , $ html ) : '' ;
93
93
}
94
94
95
95
/**
@@ -119,7 +119,7 @@ protected function attributeElement(string $key, mixed $value): mixed
119
119
return 'class=" ' .implode (' ' , $ value ).'" ' ;
120
120
}
121
121
122
- if (! is_null ($ value )) {
122
+ if (is_bool ( $ value ) || is_float ( $ value ) || is_int ( $ value ) || is_resource ( $ value ) || is_string ($ value )) {
123
123
return $ key .'=" ' .e (strval ($ value ), false ).'" ' ;
124
124
}
125
125
@@ -226,7 +226,9 @@ public function link(
226
226
$ title = $ this ->entities ($ title );
227
227
}
228
228
229
- return $ this ->toHtmlString ('<a href=" ' .$ this ->entities ($ url ).'" ' .$ this ->attributes ($ attributes ).'> ' .$ title .'</a> ' );
229
+ return $ this ->toHtmlString (
230
+ '<a href=" ' .$ this ->entities ($ url ).'" ' .$ this ->attributes ($ attributes ).'> ' .$ title .'</a> '
231
+ );
230
232
}
231
233
232
234
/**
@@ -430,7 +432,7 @@ protected function listing(string $type, array $list, array $attributes = []): H
430
432
{
431
433
$ html = '' ;
432
434
433
- if (count ($ list ) === 0 ) {
435
+ if (empty ($ list )) {
434
436
return $ html ;
435
437
}
436
438
@@ -459,8 +461,18 @@ protected function listingElement(mixed $key, string $type, mixed $value): HtmlS
459
461
if (is_array ($ value )) {
460
462
return $ this ->nestedListing ($ key , $ type , $ value );
461
463
} else {
462
- return '<li> ' .e (strval ($ value ), false ).'</li> ' ;
464
+ if (is_bool ($ value )
465
+ || is_float ($ value )
466
+ || is_int ($ value )
467
+ || is_resource ($ value )
468
+ || is_string ($ value )
469
+ || is_null ($ value )
470
+ ) {
471
+ return '<li> ' .e (strval ($ value ), false ).'</li> ' ;
472
+ }
463
473
}
474
+
475
+ return '<li> ' .$ value .'</li> ' ;
464
476
}
465
477
466
478
/**
@@ -510,7 +522,7 @@ public function dl(array $list, array $attributes = []): HtmlString
510
522
511
523
$ html .= "<dt> $ key</dt> " ;
512
524
513
- foreach ($ value as $ v_key => $ v_value ) {
525
+ foreach ($ value as $ v_value ) {
514
526
$ html .= "<dd> $ v_value</dd> " ;
515
527
}
516
528
}
@@ -549,6 +561,18 @@ public function tag(string $tag, mixed $content, array $attributes = []): HtmlSt
549
561
{
550
562
$ content = is_array ($ content ) ? implode ('' , $ content ) : $ content ;
551
563
552
- return $ this ->toHtmlString ('< ' .$ tag .$ this ->attributes ($ attributes ).'> ' .$ this ->toHtmlString (strval ($ content )).'</ ' .$ tag .'> ' );
564
+ if (is_bool ($ content )
565
+ || is_float ($ content )
566
+ || is_int ($ content )
567
+ || is_resource ($ content )
568
+ || is_string ($ content )
569
+ || is_null ($ content )
570
+ ) {
571
+ return $ this ->toHtmlString (
572
+ '< ' .$ tag .$ this ->attributes ($ attributes ).'> ' .$ this ->toHtmlString (strval ($ content )).'</ ' .$ tag .'> '
573
+ );
574
+ }
575
+
576
+ return $ this ->toHtmlString ('< ' .$ tag .$ this ->attributes ($ attributes ).'> ' .$ content .'</ ' .$ tag .'> ' );
553
577
}
554
578
}
0 commit comments