From bc0c172290babbf949fdc2ee60868d7eb714db6d Mon Sep 17 00:00:00 2001 From: YoannChabert Date: Thu, 23 Jul 2026 16:13:43 +0200 Subject: [PATCH] Pass project directory to fix --line option on PhpStorm 2026.2+ Since PhpStorm 2026.2 (build 262), the CLI rejects --line unless a project directory is passed as the first positional argument, breaking existing phpstorm:// links (e.g. from Symfony's web debug toolbar or GitHub file links). Resolve the project root from the target file's git repository and pass it before --line. --- phpstorm-url-handler | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/phpstorm-url-handler b/phpstorm-url-handler index 7e33fd8..720f61b 100755 --- a/phpstorm-url-handler +++ b/phpstorm-url-handler @@ -20,11 +20,23 @@ file=$(echo "${arg}" | sed -r "s/${pattern}/\2/") # Get the line number. line=$(echo "${arg}" | sed -r "s/${pattern}/\4/") +# Since PhpStorm 2026.2, --line is only accepted when a project directory +# is passed as the first argument. Resolve it from the target file's git root. +project=$(cd "$(dirname "${file}")" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null) + # Check if phpstorm|pstorm command exist. if type phpstorm > /dev/null; then - /usr/bin/env phpstorm --line "${line}" "${file}" + if [ -n "${project}" ]; then + /usr/bin/env phpstorm "${project}" --line "${line}" "${file}" + else + /usr/bin/env phpstorm --line "${line}" "${file}" + fi elif type pstorm > /dev/null; then - /usr/bin/env pstorm --line "${line}" "${file}" + if [ -n "${project}" ]; then + /usr/bin/env pstorm "${project}" --line "${line}" "${file}" + else + /usr/bin/env pstorm --line "${line}" "${file}" + fi fi if type wmctrl > /dev/null; then