0
votes

According to the book here, the HtmlHelper::link options are like this:

Cake\View\Helper\HtmlHelper::link(string $title, mixed $url = null, array $options = [])

But when I try to extend the helper like this:

public function link(string $title, mixed $url = null, array $options = []) {

and then pass an array to $url, I get the following error:

Argument 2 passed to App\View\Helper\MyHtmlHelper::link() must be an instance of App\View\Helper\mixed or null, array given in...

How can I extend the helper without this error?

1

1 Answers

2
votes

A couple of the types listed in the documentation are hints to the developer, not something you should actually use in your code. If you look at the actual API, you'll see that the real function definition is

public function link($title, $url = null, array $options = [])

Use that, and you should be fine.