From 81750f681348e2b3ce4c76c2e257073372167eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Kutn=C3=BD?= Date: Wed, 12 Jul 2023 11:17:21 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Html:=20proper=20types=20for=20setHtml=20an?= =?UTF-8?q?d=20addHtml=20methods=20=E2=80=93=20same=20as=20insert()=20meth?= =?UTF-8?q?od?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension.neon | 1 + stubs/HtmlStringable.stub | 8 ++++++++ stubs/Utils/Html.stub | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 stubs/HtmlStringable.stub diff --git a/extension.neon b/extension.neon index c8c147f..d8bd73a 100644 --- a/extension.neon +++ b/extension.neon @@ -18,6 +18,7 @@ parameters: - stubs/Forms/Container.stub - stubs/Forms/Form.stub - stubs/Forms/Rules.stub + - stubs/HtmlStringable.stub - stubs/Http/SessionSection.stub - stubs/Routing/Router.stub - stubs/Utils/ArrayHash.stub diff --git a/stubs/HtmlStringable.stub b/stubs/HtmlStringable.stub new file mode 100644 index 0000000..e9740a6 --- /dev/null +++ b/stubs/HtmlStringable.stub @@ -0,0 +1,8 @@ + * @implements \ArrayAccess @@ -17,4 +19,20 @@ class Html implements \ArrayAccess, \IteratorAggregate // nothing } + /** + * @param string|HtmlStringable $html + */ + public function setHtml(mixed $html): static + { + // nothing + } + + /** + * @param string|HtmlStringable $child + */ + final public function addHtml(mixed $child): static + { + // nothing + } + } From c82fd5ba1d706378ba7e12d70b7c44ce074b503f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Kutn=C3=BD?= Date: Wed, 12 Jul 2023 11:49:15 +0200 Subject: [PATCH 2/2] HtmlStringable stub support for older PHP versions --- stubs/HtmlStringable.stub | 4 +++- stubs/Utils/Html.stub | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/stubs/HtmlStringable.stub b/stubs/HtmlStringable.stub index e9740a6..17cf7c7 100644 --- a/stubs/HtmlStringable.stub +++ b/stubs/HtmlStringable.stub @@ -2,7 +2,9 @@ namespace Nette; -interface HtmlStringable extends \Stringable +interface HtmlStringable { + public function __toString(): string; + } diff --git a/stubs/Utils/Html.stub b/stubs/Utils/Html.stub index d13b3fb..b4983de 100644 --- a/stubs/Utils/Html.stub +++ b/stubs/Utils/Html.stub @@ -19,14 +19,6 @@ class Html implements \ArrayAccess, \IteratorAggregate // nothing } - /** - * @param string|HtmlStringable $html - */ - public function setHtml(mixed $html): static - { - // nothing - } - /** * @param string|HtmlStringable $child */