Skip to content

Conversation

@haszi
Copy link
Contributor

@haszi haszi commented Jan 1, 2025

Minimal fix for FQN class and method/function linking not working. Closes GH-170.

@haszi haszi force-pushed the Fix-FQN-Class-and-method-links branch from 2991519 to 80c2cd3 Compare January 1, 2025 14:01
@haszi
Copy link
Contributor Author

haszi commented Jan 5, 2025

Added a method for normalizing the FQNs. As it was trivial, the same fix was applied to constants and properties.

@haszi haszi changed the title Fix FQN class and method linking Fix FQN class, method, property and constant linking Jan 5, 2025
@haszi haszi requested review from Girgias and alfsb January 5, 2025 16:52
@Girgias Girgias merged commit c22feec into php:master Jan 5, 2025
7 checks passed
Copy link
Member

@alfsb alfsb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already merged, I know. Only to comment what can make te code easier in future.

}

private function convertConstantNameToId(string $constantName): string {
$tempLinkValue = str_replace(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a future version, move all transformations inside the normalize function (trim, replace), to make understanding the code easier.

return $value;
}

$tempLinkValue = str_replace(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replace list here differs from other point. Maybe there is necessary two normalize functions, or if the difference is accidental, to test what list of substitutions is the correct.

}

public function format_type_text($type, $tagname) {
$t = strtr(strtolower($type), ["_" => "-", "\\" => "-"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note how these substations lists are copied everywhere.


public function format_classname_text($value, $tag) {
if (($filename = $this->getClassnameLink(strtolower($value))) !== null && $this->cchunk["class_name_ref"] !== strtolower($value)) {
if (($filename = $this->getClassnameLink($this->normalizeFQN($value))) !== null && $this->cchunk["class_name_ref"] !== strtolower($value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat unrelated, but in a future version, first test if getClassnameLink() with fails with raw string, and then test again with plain \trim(). In this case, generate the link as usual but generate an warning, as this a source error (unexpected whitespace around type/constante/etc tags).

@haszi haszi deleted the Fix-FQN-Class-and-method-links branch January 12, 2025 18:43
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.

Linking for FQN of Classes/Methods does not work

3 participants