From 4c8d89e78481912a33f3a9d0790fb5614fdbd83f Mon Sep 17 00:00:00 2001 From: Igor Alexandrovich Date: Thu, 10 Apr 2025 16:47:39 +0400 Subject: [PATCH 1/2] php improvements --- core/php_wrapper.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/php_wrapper.py b/core/php_wrapper.py index 9222c1a..4110188 100644 --- a/core/php_wrapper.py +++ b/core/php_wrapper.py @@ -25,7 +25,7 @@ def getConsoleLogTypes(self): return [] def getConsoleStr(self): - return "{variable}" + return settings().get('php').get('consoleStr', "{title}, {variable}") def getConsoleSingleQuotes(self): return True @@ -103,13 +103,14 @@ def get_wrapper(self, view, var, indent_str, insert_before): consoleArr = consoleStr.split(separator) - t = consoleArr[0] + text = var.replace("'", "\\'") + text = text.replace("\"", "\\\"") + text = '\'' + text + '\'' - if len(consoleArr) >= 2: - v = ', '.join(consoleArr[1:]) - else: - v = t + var = var.replace(";", ',') + v = ', '.join(consoleArr) + tmpl = indent_str if insert_before else ("\n" + indent_str) openPre = "echo '
'; " if preTag else ""
@@ -118,7 +119,7 @@ def get_wrapper(self, view, var, indent_str, insert_before):
 		dieStr = " die();" if dieAfterLog else ""
 
 		a = "{2}{0}({1});{3}{4}".format("->".join(consoleFunc), v, openPre, closePre, dieStr)
-		a = a.format(variable=var)
+		a = a.format(title=text, variable=var)
 
 		tmpl += a
 

From 64d59cd7ccd92cae8c6d63c4dbe3997d10090aed Mon Sep 17 00:00:00 2001
From: Igor Alexandrovich 
Date: Mon, 3 Nov 2025 12:28:39 +0400
Subject: [PATCH 2/2] Update php_wrapper.py

Better variable handling, also adding file and line number
---
 core/php_wrapper.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/php_wrapper.py b/core/php_wrapper.py
index 4110188..578d7c3 100644
--- a/core/php_wrapper.py
+++ b/core/php_wrapper.py
@@ -51,6 +51,9 @@ def create(self, view, edit, cursor, insert_before):
 
 			var_text = view.substr(word).strip()
 
+			if view.substr(word.begin() - 1) == '$':
+				var_text = '$' + var_text
+
 			# if selection is empty and there is no word under cursor use clipboard
 			if not var_text:
 				var_text = sublime.get_clipboard()
@@ -118,7 +121,7 @@ def get_wrapper(self, view, var, indent_str, insert_before):
 
 		dieStr = " die();" if dieAfterLog else ""
 
-		a = "{2}{0}({1});{3}{4}".format("->".join(consoleFunc), v, openPre, closePre, dieStr)
+		a = "{2}{0}(__FILE__.':'.__LINE__, {1});{3}{4}".format("->".join(consoleFunc), v, openPre, closePre, dieStr)
 		a = a.format(title=text, variable=var)
 
 		tmpl += a