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

Fix FQN class, method, property and constant linking #185

Merged
merged 5 commits into from
Jan 5, 2025

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 alfsb and Girgias 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.

@@ -1811,7 +1811,7 @@ 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.

@@ -1855,7 +1855,7 @@ public function format_property_text($value, $tag) {
$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.

@@ -666,7 +666,7 @@ public function format_type_methodparam_text($type, $tagname) {
}

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.

@@ -880,7 +880,7 @@ public function format_classsynopsis_oo_name_text($value, $tag) {
}

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