Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html: proper types for setHtml and addHtml methods – same as insert() method #128

Open
wants to merge 2 commits into
base: 1.1.x
Choose a base branch
from

Conversation

vitkutny
Copy link

fixes Nette\Utils\Html::insert(): Argument #2 ($child) must be of type Nette\HtmlStringable|string, XY given

@ondrejmirtes
Copy link
Member

Please show a piece of code for which "Nette\Utils\Html::insert(): Argument #2 ($child) must be of type Nette\HtmlStringable|string, XY given" is currently reported and which this PR should fix.

Also - did you first try to send a PR to https://github.com/nette/utils?

@vitkutny
Copy link
Author

Please show a piece of code for which "Nette\Utils\Html::insert(): Argument #2 ($child) must be of type Nette\HtmlStringable|string, XY given" is currently reported and which this PR should fix.

addHtml method only calls insert method with parameter type HtmlStringable|string. This stub update prevents from passing only \Stringable (or any other type than HtmlStringable|string) into addHtml

namespace Nette\Utils;

class Html implements \ArrayAccess, \Countable, \IteratorAggregate, HtmlStringable
{
	/**
	 * Adds new element's child.
	 */
	final public function addHtml(mixed $child): static
	{
		return $this->insert(null, $child);
	}
	
	/**
	 * Inserts child node.
	 */
	public function insert(?int $index, HtmlStringable|string $child, bool $replace = false): static
	{
	}
}

Also - did you first try to send a PR to https://github.com/nette/utils?

Right, I did not. I will :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants