mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +01:00
Jump to PHP docs from symbol search more often
Summary: It's kind of nice to type `s explode` in jump nav and have it just work. This involves weakening a bunch of the request parameter checks, but the only real extra assumption is that language defaults to PHP... which is not that big of a stretch, and it's not like we know about any other languages' documentation. It'd be better to have builtins be more first-class and less awkward hack, but that seems hard. Test Plan: Search for symbols. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3302
This commit is contained in:
parent
6623a721d3
commit
627584f501
1 changed files with 14 additions and 16 deletions
|
@ -68,24 +68,22 @@ final class DiffusionSymbolController extends DiffusionController {
|
|||
|
||||
// For PHP builtins, jump to php.net documentation.
|
||||
if ($request->getBool('jump') && count($symbols) == 0) {
|
||||
if ($request->getStr('lang') == 'php') {
|
||||
switch ($request->getStr('type')) {
|
||||
case 'function':
|
||||
$functions = get_defined_functions();
|
||||
if (in_array($this->name, $functions['internal'])) {
|
||||
if ($request->getStr('lang', 'php') == 'php') {
|
||||
if ($request->getStr('type', 'function') == 'function') {
|
||||
$functions = get_defined_functions();
|
||||
if (in_array($this->name, $functions['internal'])) {
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('http://www.php.net/function.'.$this->name);
|
||||
}
|
||||
}
|
||||
if ($request->getStr('type', 'class') == 'class') {
|
||||
if (class_exists($this->name, false) ||
|
||||
interface_exists($this->name, false)) {
|
||||
if (id(new ReflectionClass($this->name))->isInternal()) {
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('http://www.php.net/function.'.$this->name);
|
||||
->setURI('http://www.php.net/class.'.$this->name);
|
||||
}
|
||||
break;
|
||||
case 'class':
|
||||
if (class_exists($this->name, false) ||
|
||||
interface_exists($this->name, false)) {
|
||||
if (id(new ReflectionClass($this->name))->isInternal()) {
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('http://www.php.net/class.'.$this->name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue