File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 39
39
use function count ;
40
40
use function dirname ;
41
41
use function extension_loaded ;
42
+ use function get_cfg_var ;
42
43
use function getenv ;
43
44
use function ini_get ;
44
45
use function is_array ;
45
46
use function is_file ;
46
47
use function is_readable ;
48
+ use function is_string ;
47
49
use function spl_object_id ;
48
50
use function sprintf ;
49
51
use function str_ends_with ;
52
+ use function strtr ;
50
53
use function substr ;
51
54
52
55
/**
@@ -149,6 +152,12 @@ public function create(
149
152
150
153
$ configurator ->setAllConfigFiles ($ allConfigFiles );
151
154
155
+ if (!array_key_exists ('editorUrl ' , $ projectConfig ['parameters ' ])) {
156
+ $ configurator ->addParameters ([
157
+ 'editorUrl ' => $ this ->getEditorUrlFromPhpIni (),
158
+ ]);
159
+ }
160
+
152
161
$ container = $ configurator ->createContainer ()->getByType (Container::class);
153
162
$ this ->validateParameters ($ container ->getParameters (), $ projectConfig ['parametersSchema ' ]);
154
163
self ::postInitializeContainer ($ container );
@@ -391,4 +400,23 @@ private function processArgument($argument, bool $required = true)
391
400
return $ argument ;
392
401
}
393
402
403
+ /**
404
+ * Try to fetch an editor URL from php.ini by reading xdebug configuration.
405
+ *
406
+ * This works even if the xdebug extension is not loaded.
407
+ */
408
+ private function getEditorUrlFromPhpIni (): ?string
409
+ {
410
+ $ xdebugFileLinkFormat = ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
411
+
412
+ if (is_string ($ xdebugFileLinkFormat ) && $ xdebugFileLinkFormat !== '' ) {
413
+ return strtr ($ xdebugFileLinkFormat , [
414
+ '%f ' => '%file% ' ,
415
+ '%l ' => '%line% ' ,
416
+ ]);
417
+ }
418
+
419
+ return null ;
420
+ }
421
+
394
422
}
You can’t perform that action at this time.
0 commit comments