mirror of
https://github.com/filp/whoops.git
synced 2026-09-01 13:08:02 +00:00
Merge pull request #45 from cs278/feature/xdebug-editor
Add support for xdebug editor links
This commit is contained in:
@@ -75,6 +75,7 @@ The following editors are currently supported by default.
|
||||
- `emacs` - Emacs
|
||||
- `textmate` - Textmate
|
||||
- `macvim` - MacVim
|
||||
- `xdebug` - xdebug (uses [xdebug.file_link_format](http://xdebug.org/docs/all_settings#file_link_format))
|
||||
|
||||
Adding your own editor is simple:
|
||||
|
||||
|
||||
@@ -48,6 +48,19 @@ class PrettyPageHandler extends Handler
|
||||
'macvim' => 'mvim://open/?url=file://%file&line=%line'
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (extension_loaded('xdebug')) {
|
||||
// Register editor using xdebug's file_link_format option.
|
||||
$this->editors['xdebug'] = function($file, $line) {
|
||||
return str_replace(array('%f', '%l'), array($file, $line), ini_get('xdebug.file_link_format'));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
|
||||
@@ -182,4 +182,33 @@ class PrettyPageHandlerTest extends TestCase
|
||||
'cool beans hello:20'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEditorXdebug()
|
||||
{
|
||||
if (!extension_loaded('xdebug')) {
|
||||
$this->markTestSkipped('xdebug is not available');
|
||||
}
|
||||
|
||||
$originalValue = ini_get('xdebug.file_link_format');
|
||||
|
||||
$handler = $this->getHandler();
|
||||
$handler->setEditor('xdebug');
|
||||
|
||||
ini_set('xdebug.file_link_format', '%f:%l');
|
||||
|
||||
$this->assertEquals(
|
||||
'/foo/bar.php:10',
|
||||
$handler->getEditorHref('/foo/bar.php', 10)
|
||||
);
|
||||
|
||||
ini_set('xdebug.file_link_format', 'subl://open?url=%f&line=%l');
|
||||
|
||||
// xdebug doesn't do any URL encoded, matching that behaviour.
|
||||
$this->assertEquals(
|
||||
'subl://open?url=/foo/with space?.php&line=2324',
|
||||
$handler->getEditorHref('/foo/with space?.php', 2324)
|
||||
);
|
||||
|
||||
ini_set('xdebug.file_link_format', $originalValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user