From 12bf347ca720baaa4ad3088b4f18c88e5c7067cc Mon Sep 17 00:00:00 2001
From: Antoine Lamirault
Date: Thu, 18 May 2023 19:20:28 +0200
Subject: [PATCH] Method reference generate link with scoll to text fragment
---
src/Reference/MethodReference.php | 3 ++-
tests/fixtures/expected/blocks/references/method.html | 2 +-
tests/fixtures/expected/main/datetime.html | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/Reference/MethodReference.php b/src/Reference/MethodReference.php
index baacc468..632aaa26 100644
--- a/src/Reference/MethodReference.php
+++ b/src/Reference/MethodReference.php
@@ -39,10 +39,11 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
$methodName = explode('::', $data)[1];
+ $scrollTextFragment = sprintf('#:~:text=%s', rawurlencode('function '.$methodName));
return new ResolvedReference(
$environment->getCurrentFileName(),
$methodName.'()',
- sprintf('%s/%s.php#method_%s', $this->symfonyRepositoryUrl, str_replace('\\', '/', $className), $methodName),
+ sprintf('%s/%s.php%s', $this->symfonyRepositoryUrl, str_replace('\\', '/', $className), $scrollTextFragment),
[],
[
'title' => sprintf('%s::%s()', $className, $methodName),
diff --git a/tests/fixtures/expected/blocks/references/method.html b/tests/fixtures/expected/blocks/references/method.html
index 4c58d318..6046098e 100644
--- a/tests/fixtures/expected/blocks/references/method.html
+++ b/tests/fixtures/expected/blocks/references/method.html
@@ -1 +1 @@
-getCurrentRequest()
+getCurrentRequest()
diff --git a/tests/fixtures/expected/main/datetime.html b/tests/fixtures/expected/main/datetime.html
index c75b859e..c3026372 100644
--- a/tests/fixtures/expected/main/datetime.html
+++ b/tests/fixtures/expected/main/datetime.html
@@ -76,7 +76,7 @@
This is a little tip about something! We an also talk about specific
-methods: doRequest().
+methods: doRequest().
Or a namespace: Constraints.
Or a PHP function: parse_ini_file.
Or a PHP method! Locale::getDefault().