Skip to content

Commit 8cbb471

Browse files
committed
Allow stringable on methods that return html
1 parent f25f279 commit 8cbb471

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/Element/Element.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ public static function indexHtml(
13111311
bool $includeContainer,
13121312
bool $selectable,
13131313
bool $sortable,
1314-
): string {
1314+
): string|Stringable {
13151315
$request = Craft::$app->getRequest();
13161316
$static = $viewState['static'] ?? false;
13171317
$variables = [
@@ -3640,7 +3640,7 @@ protected function uiLabel(): ?string
36403640
/**
36413641
* {@inheritdoc}
36423642
*/
3643-
public function getChipLabelHtml(): string
3643+
public function getChipLabelHtml(): string|Stringable
36443644
{
36453645
return Html::encode($this->getUiLabel());
36463646
}
@@ -3878,7 +3878,7 @@ public function getPostEditUrl(): ?string
38783878
/**
38793879
* {@inheritdoc}
38803880
*/
3881-
public function getAdditionalButtons(): string
3881+
public function getAdditionalButtons(): string|Stringable
38823882
{
38833883
// Fire a 'defineAdditionalButtons' event
38843884
if ($this->hasEventHandlers(self::EVENT_DEFINE_ADDITIONAL_BUTTONS)) {
@@ -5780,7 +5780,7 @@ public function getAttributeHtml(string $attribute): string|Stringable
57805780
/**
57815781
* {@inheritdoc}
57825782
*/
5783-
public function getInlineAttributeInputHtml(string $attribute): string
5783+
public function getInlineAttributeInputHtml(string $attribute): string|Stringable
57845784
{
57855785
// Fire a 'defineInlineAttributeInputHtml' event
57865786
if ($this->hasEventHandlers(self::EVENT_DEFINE_INLINE_ATTRIBUTE_INPUT_HTML)) {
@@ -5996,7 +5996,7 @@ protected function attributeHtml(string $attribute): string|Stringable
59965996
}
59975997
}
59985998

5999-
private function contentBlockAttributeHtml(string $attribute): string
5999+
private function contentBlockAttributeHtml(string $attribute): string|Stringable
60006000
{
60016001
$parts = explode('.', $attribute);
60026002
$uid = Str::after(array_shift($parts), 'contentBlock:');
@@ -6021,7 +6021,7 @@ private function contentBlockAttributeHtml(string $attribute): string
60216021
return $block->getAttributeHtml(implode('.', $parts));
60226022
}
60236023

6024-
private function generatedFieldAttributeHtml(string $attribute): string
6024+
private function generatedFieldAttributeHtml(string $attribute): string|Stringable
60256025
{
60266026
$uid = Str::after($attribute, 'generatedField:');
60276027

@@ -6076,7 +6076,7 @@ private function _getFieldFromAlternativeLayouts($layoutElementUid): ?FieldInter
60766076
* @see getInlineAttributeInputHtml()
60776077
* @since 5.0.0
60786078
*/
6079-
protected function inlineAttributeInputHtml(string $attribute): string
6079+
protected function inlineAttributeInputHtml(string $attribute): string|Stringable
60806080
{
60816081
// Is this a custom field?
60826082
$field = null;
@@ -6123,7 +6123,7 @@ protected function inlineAttributeInputHtml(string $attribute): string
61236123
/**
61246124
* {@inheritdoc}
61256125
*/
6126-
public function getSidebarHtml(bool $static): string
6126+
public function getSidebarHtml(bool $static): string|Stringable
61276127
{
61286128
$components = [];
61296129

@@ -6162,7 +6162,7 @@ public function getSidebarHtml(bool $static): string
61626162
*
61636163
* @since 3.7.0
61646164
*/
6165-
protected function metaFieldsHtml(bool $static): string
6165+
protected function metaFieldsHtml(bool $static): string|Stringable
61666166
{
61676167
// Fire a 'defineMetaFieldsHtml' event
61686168
if ($this->hasEventHandlers(self::EVENT_DEFINE_META_FIELDS_HTML)) {
@@ -6182,7 +6182,7 @@ protected function metaFieldsHtml(bool $static): string
61826182
*
61836183
* @since 3.7.0
61846184
*/
6185-
protected function slugFieldHtml(bool $static): string
6185+
protected function slugFieldHtml(bool $static): string|Stringable
61866186
{
61876187
$slug = isset($this->slug) && ! ElementHelper::isTempSlug($this->slug) ? $this->slug : null;
61886188

@@ -6219,7 +6219,7 @@ protected function showStatusField(): bool
62196219
*
62206220
* @since 4.0.0
62216221
*/
6222-
protected function statusFieldHtml(): string
6222+
protected function statusFieldHtml(): string|Stringable
62236223
{
62246224
$supportedSites = ElementHelper::supportedSitesForElement($this, true);
62256225
$allEditableSiteIds = Sites::getEditableSiteIds()->all();
@@ -6273,7 +6273,7 @@ protected function statusFieldHtml(): string
62736273
*
62746274
* @since 4.0.0
62756275
*/
6276-
protected function notesFieldHtml(): string
6276+
protected function notesFieldHtml(): string|Stringable
62776277
{
62786278
// todo: this should accept a $static arg
62796279
return Cp::textareaFieldHtml([

yii2-adapter/legacy/base/ElementInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public static function indexHtml(
455455
bool $includeContainer,
456456
bool $selectable,
457457
bool $sortable,
458-
): string;
458+
): string|Stringable;
459459

460460
/**
461461
* Returns the total number of elements that will be shown on an element index, for the given element query.
@@ -899,7 +899,7 @@ public function setUiLabelPath(array $path): void;
899899
* @return string
900900
* @since 5.0.0
901901
*/
902-
public function getChipLabelHtml(): string;
902+
public function getChipLabelHtml(): string|Stringable;
903903

904904
/**
905905
* Returns whether chips and cards for this element should include a status indicator.
@@ -1072,7 +1072,7 @@ public function getCpRevisionsUrl(): ?string;
10721072
* @return string
10731073
* @since 4.0.0
10741074
*/
1075-
public function getAdditionalButtons(): string;
1075+
public function getAdditionalButtons(): string|Stringable;
10761076

10771077
/**
10781078
* Returns alternative form actions for the element.
@@ -1818,7 +1818,7 @@ public function getAttributeHtml(string $attribute): string|Stringable;
18181818
* @return string The HTML that should be shown for the element input.
18191819
* @since 5.0.0
18201820
*/
1821-
public function getInlineAttributeInputHtml(string $attribute): string;
1821+
public function getInlineAttributeInputHtml(string $attribute): string|Stringable;
18221822

18231823
/**
18241824
* Returns the HTML for any fields/info that should be shown within the editor sidebar.
@@ -1827,7 +1827,7 @@ public function getInlineAttributeInputHtml(string $attribute): string;
18271827
* @return string
18281828
* @since 3.7.0
18291829
*/
1830-
public function getSidebarHtml(bool $static): string;
1830+
public function getSidebarHtml(bool $static): string|Stringable;
18311831

18321832
/**
18331833
* Returns element metadata that should be shown within the editor sidebar.

0 commit comments

Comments
 (0)