Skip to content

Commit 5adfbc4

Browse files
authored
Raise yiisoft/html version to ^3.13 || ^4.0 (#306)
1 parent b7779f8 commit 5adfbc4

35 files changed

Lines changed: 1175 additions & 1174 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.1.1 under development
44

5+
- Enh #306: Raise `yiisoft/html` version to `^3.13 || ^4.0` (@vjik)
56
- Enh #305: Add `tabIndex()` method to `Button` widget (@Mister-42)
67

78
## 1.1.0 March 06, 2026

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"require": {
1919
"php": "8.1 - 8.5",
20-
"yiisoft/html": "^3.0",
20+
"yiisoft/html": "^3.13 || ^4.0",
2121
"yiisoft/widget": "^2.0"
2222
},
2323
"require-dev": {

src/Accordion.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ public function render(): string
520520

521521
$id = $this->getId();
522522

523-
return Div::tag()
523+
return (new Div())
524524
->addAttributes($attributes)
525525
->addClass(self::NAME, $classes, ...$this->cssClasses)
526526
->addContent("\n", $this->renderItems($id), "\n")
@@ -569,14 +569,14 @@ private function renderBody(AccordionItem $accordionItem, string $parentId, stri
569569

570570
unset($bodyAttributes['class'], $collapseAttributes['class']);
571571

572-
return Div::tag()
572+
return (new Div())
573573
->attribute('data-bs-parent', $this->alwaysOpen ? null : '#' . $parentId)
574574
->addAttributes($collapseAttributes)
575575
->addClass(self::CLASS_COLLAPSE, $accordionItem->isActive() ? 'show' : null, $classesCollapseAttributes)
576576
->id($collapseId)
577577
->addContent(
578578
"\n",
579-
Div::tag()
579+
(new Div())
580580
->addAttributes($bodyAttributes)
581581
->addClass(self::CLASS_BODY, $classesBodyAttributes)
582582
->addContent("\n", $accordionItem->getBody(), "\n")
@@ -658,7 +658,7 @@ private function renderItem(AccordionItem $accordionItem, string $parentId): str
658658
/** @psalm-var non-empty-string $collapseId */
659659
$collapseId = $accordionItem->getId();
660660

661-
return Div::tag()->addClass(self::CLASS_ITEM)
661+
return (new Div())->addClass(self::CLASS_ITEM)
662662
->addContent(
663663
"\n",
664664
$this->renderHeader($accordionItem, $collapseId),

src/Alert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public function render(): string
567567

568568
$content = preg_replace("/\n{2}/", "\n", $content) ?? '';
569569

570-
return Div::tag()->addAttributes($attributes)->content($content)->encode(false)->id($this->getId())->render();
570+
return (new Div())->addAttributes($attributes)->content($content)->encode(false)->id($this->getId())->render();
571571
}
572572

573573
/**

src/Breadcrumbs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public function render(): string
407407
}
408408

409409

410-
return Nav::tag()
410+
return (new Nav())
411411
->addAttributes($attributes)
412412
->addClass(...$this->cssClasses)
413413
->content("\n", $this->renderList(), "\n")
@@ -493,7 +493,7 @@ private function renderItem(BreadcrumbLink $breadcrumbLink): string
493493
$itemsAttributes['aria-current'] = 'page';
494494
}
495495

496-
return Li::tag()
496+
return (new Li())
497497
->addAttributes($itemsAttributes)
498498
->addClass(
499499
self::ITEM_NAME,
@@ -519,7 +519,7 @@ private function renderLink(BreadcrumbLink $breadcrumbLink): string
519519

520520
return match ($url) {
521521
null => $label,
522-
default => A::tag()
522+
default => (new A())
523523
->attributes($this->linkAttributes)
524524
->addAttributes($breadcrumbLink->getAttributes())
525525
->content($label)

src/Button.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public function type(ButtonType $type): self
528528
{
529529
$new = clone $this;
530530
$new->tag = match ($type) {
531-
ButtonType::LINK => A::tag(),
531+
ButtonType::LINK => (new A()),
532532
ButtonType::RESET => ButtonTag::reset(''),
533533
ButtonType::RESET_INPUT => Input::resetButton(),
534534
ButtonType::SUBMIT => ButtonTag::submit(''),
@@ -584,7 +584,7 @@ public function render(): string
584584
{
585585
$attributes = $this->attributes;
586586
$classes = $attributes['class'] ?? null;
587-
$tag = $this->tag ?? ButtonTag::tag()->button('');
587+
$tag = $this->tag ?? (new ButtonTag())->button('');
588588

589589
unset($attributes['class'], $attributes['id']);
590590

src/ButtonGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function render(): string
299299
return '';
300300
}
301301

302-
return Div::tag()
302+
return (new Div())
303303
->attributes($attributes)
304304
->attribute('role', 'group')
305305
->addClass(

src/ButtonToolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function render(): string
274274
return '';
275275
}
276276

277-
return Div::tag()
277+
return (new Div())
278278
->attributes($attributes)
279279
->attribute('role', 'toolbar')
280280
->addClass(

src/Carousel.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* <?= Carousel::widget()
2727
* ->id('carouselExample')
2828
* ->items(
29-
* CarouselItem::to(Img::tag()->alt('First slide')->src('image-1.jpg'), active: true),
30-
* CarouselItem::to(Img::tag()->alt('Second slide')->src('image-2.jpg')),
31-
* CarouselItem::to(Img::tag()->alt('Third slide')->src('image-3.jpg')),
29+
* CarouselItem::to((new Img())->alt('First slide')->src('image-1.jpg'), active: true),
30+
* CarouselItem::to((new Img())->alt('Second slide')->src('image-2.jpg')),
31+
* CarouselItem::to((new Img())->alt('Third slide')->src('image-3.jpg')),
3232
* )
3333
* ?>
3434
* ```
@@ -409,9 +409,9 @@ public function id(bool|string $id): self
409409
* Example usage:
410410
* ```php
411411
* $carousel->items(
412-
* CarouselItem::to(Img::tag()->alt('First slide')->src('image-1.jpg'), active: true),
413-
* CarouselItem::to(Img::tag()->alt('Second slide')->src('image-2.jpg')),
414-
* CarouselItem::to(Img::tag()->alt('Third slide')->src('image-3.jpg')),
412+
* CarouselItem::to((new Img())->alt('First slide')->src('image-1.jpg'), active: true),
413+
* CarouselItem::to((new Img())->alt('Second slide')->src('image-2.jpg')),
414+
* CarouselItem::to((new Img())->alt('Third slide')->src('image-3.jpg')),
415415
* );
416416
*/
417417
public function items(CarouselItem ...$items): self
@@ -498,7 +498,7 @@ public function render(): string
498498

499499
Html::addCssClass($attributes, [self::NAME, self::CLASS_SLIDE, $classes, ...$this->cssClasses]);
500500

501-
return Div::tag()
501+
return (new Div())
502502
->attributes($attributes)
503503
->addContent(
504504
"\n",
@@ -549,12 +549,12 @@ private function renderControlNext(string $id): string
549549
->addClass(self::CLASS_CAROUSEL_CONTROL_NEXT)
550550
->addContent(
551551
"\n",
552-
Span::tag()
552+
(new Span())
553553
->addAttributes(['aria-hidden' => 'true'])
554554
->addClass(self::CLASS_CAROUSEL_CONTROL_NEXT_ICON)
555555
->render(),
556556
"\n",
557-
Span::tag()->addClass('visually-hidden')->addContent($this->controlNextLabel)->render(),
557+
(new Span())->addClass('visually-hidden')->addContent($this->controlNextLabel)->render(),
558558
"\n",
559559
)
560560
->encode(false)
@@ -580,12 +580,12 @@ private function renderControlPrevious(string $id): string
580580
->addClass(self::CLASS_CAROUSEL_CONTROL_PREV)
581581
->addContent(
582582
"\n",
583-
Span::tag()
583+
(new Span())
584584
->addAttributes(['aria-hidden' => 'true'])
585585
->addClass(self::CLASS_CAROUSEL_CONTROL_PREV_ICON)
586586
->render(),
587587
"\n",
588-
Span::tag()->addClass('visually-hidden')->addContent($this->controlPreviousLabel)->render(),
588+
(new Span())->addClass('visually-hidden')->addContent($this->controlPreviousLabel)->render(),
589589
"\n",
590590
)
591591
->encode(false)
@@ -643,7 +643,7 @@ private function renderItem(CarouselItem $carouselItem, bool $active): string
643643
);
644644
}
645645

646-
$captionContainerTag = Div::tag()
646+
$captionContainerTag = (new Div())
647647
->addClass(self::CLASS_CAROUSEL_CAPTION)
648648
->addContent(
649649
"\n",
@@ -658,7 +658,7 @@ private function renderItem(CarouselItem $carouselItem, bool $active): string
658658
) . "\n";
659659
}
660660

661-
return Div::tag()
661+
return (new Div())
662662
->addClass(
663663
self::CLASS_CAROUSEL_ITEM,
664664
$carouselItem->isActive() || $active ? 'active' : null,
@@ -704,15 +704,15 @@ private function renderItems(string $id): string
704704
}
705705

706706
if ($this->showIndicators) {
707-
$renderIndicators = Div::tag()
707+
$renderIndicators = (new Div())
708708
->addClass(self::CLASS_CAROUSEL_INDICATORS)
709709
->addContent("\n" . implode("\n", $indicators) . "\n")
710710
->encode(false)
711711
->render() . "\n";
712712
}
713713

714714
return $renderIndicators
715-
. Div::tag()
715+
. (new Div())
716716
->addClass(self::CLASS_CAROUSEL_INNER)
717717
->addContent("\n" . implode("\n", $items) . "\n")
718718
->encode(false)

src/Collapse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,12 @@ public function render(): string
357357

358358
foreach ($this->items as $item) {
359359
if ($item->getContent() !== '') {
360-
$collapseDiv = Div::tag()
360+
$collapseDiv = (new Div())
361361
->addClass(self::NAME, ...$this->cssClasses)
362362
->addAttributes($this->attributes)
363363
->addContent(
364364
"\n",
365-
Div::tag()
365+
(new Div())
366366
->addAttributes($this->cardBodyAttributes)
367367
->addClass(self::CARD, self::CARD_BODY)
368368
->addContent(
@@ -378,7 +378,7 @@ public function render(): string
378378
$collapseDiv = $collapseDiv->addClass(self::COLLAPSE_MULTIPLE);
379379

380380
if ($item->getTogglerMultiple() === false) {
381-
$collapse[] = Div::tag()->addClass('col')->addContent("\n", $collapseDiv, "\n");
381+
$collapse[] = (new Div())->addClass('col')->addContent("\n", $collapseDiv, "\n");
382382
}
383383
} else {
384384
$collapse[] = $collapseDiv;
@@ -403,7 +403,7 @@ private function renderCollapse(array $collapse): string
403403
$collapseContent = implode("\n", $collapse);
404404

405405
return $this->container
406-
? Div::tag()
406+
? (new Div())
407407
->addAttributes($this->containerAttributes)
408408
->addContent("\n", $collapseContent, "\n")
409409
->encode(false)

0 commit comments

Comments
 (0)