php-markdown icon indicating copy to clipboard operation
php-markdown copied to clipboard

Update Markdown.php

Open edgering opened this issue 1 year ago • 6 comments

edgering avatar Apr 20 '23 21:04 edgering

I don't see how that change makes sense. No one is calling these callback functions with a second parameter.

michelf avatar Apr 21 '23 02:04 michelf

Sure. It's just matched as an undefined variable in validators.

edgering avatar Apr 21 '23 07:04 edgering

The change makes sense; $text has no value before this PR. I suggest merging to prevent validators from screaming out.

wilson1000-MoJ avatar Jul 06 '23 12:07 wilson1000-MoJ

What makes no sense here is to add a function parameter. This function is never going to receive a $text parameter, and has no reason to receive one either, so it's misleading. A local variable would make more sense.

michelf avatar Jul 06 '23 13:07 michelf

Put like that @michelf, I'm behind you. Something simple like this might be better. Although, it is important to note that encodeURLAttribute() is setting $text by reference - to evade any confusion.

/**
 * Parse URL callback
 * @var string|null $text set by reference in encodeURLAttribute() 
 * @param array $matches
 * @return string
 */
protected function _doAutoLinks_url_callback($matches) {
        $text = null;
	$url = $this->encodeURLAttribute($matches[1], $text);
	$link = "<a href=\"$url\">$text</a>";
	return $this->hashPart($link);
}

@edgering does this make sense to you?

wilson1000-MoJ avatar Jul 06 '23 15:07 wilson1000-MoJ

Absolutely. Thank you.

edgering avatar Jul 10 '23 20:07 edgering