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 3939use function count ;
4040use function dirname ;
4141use function extension_loaded ;
42+ use function get_cfg_var ;
4243use function getenv ;
4344use function ini_get ;
4445use function is_array ;
4546use function is_file ;
4647use function is_readable ;
48+ use function is_string ;
4749use function spl_object_id ;
4850use function sprintf ;
4951use function str_ends_with ;
52+ use function strtr ;
5053use function substr ;
5154
5255/**
@@ -149,6 +152,12 @@ public function create(
149152
150153 $ configurator ->setAllConfigFiles ($ allConfigFiles );
151154
155+ if (!array_key_exists ('editorUrl ' , $ projectConfig ['parameters ' ])) {
156+ $ configurator ->addParameters ([
157+ 'editorUrl ' => $ this ->getEditorUrlFromPhpIni (),
158+ ]);
159+ }
160+
152161 $ container = $ configurator ->createContainer ()->getByType (Container::class);
153162 $ this ->validateParameters ($ container ->getParameters (), $ projectConfig ['parametersSchema ' ]);
154163 self ::postInitializeContainer ($ container );
@@ -391,4 +400,23 @@ private function processArgument($argument, bool $required = true)
391400 return $ argument ;
392401 }
393402
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+
394422}
You can’t perform that action at this time.
0 commit comments