From ccc258fa85cc65e6e0d35e9cfca0e079fb910d64 Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 21 Mar 2012 12:18:05 -0700 Subject: [PATCH] Jump to PHP Manual for PHP's internal classes and interfaces in symbol search Test Plan: Clicked on `Exception` in `throw new Exception`. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1978 --- .../symbol/DiffusionSymbolController.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/applications/diffusion/controller/symbol/DiffusionSymbolController.php b/src/applications/diffusion/controller/symbol/DiffusionSymbolController.php index 4d5a69702e..9e4d5a35d1 100644 --- a/src/applications/diffusion/controller/symbol/DiffusionSymbolController.php +++ b/src/applications/diffusion/controller/symbol/DiffusionSymbolController.php @@ -65,11 +65,23 @@ 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') { - if ($request->getStr('type') == 'function') { - if (in_array($this->name, idx(get_defined_functions(), 'internal'))) { - return id(new AphrontRedirectResponse()) - ->setURI('http://www.php.net/function.'.$this->name); - } + switch ($request->getStr('type')) { + case 'function': + $functions = get_defined_functions(); + if (in_array($this->name, $functions['internal'])) { + return id(new AphrontRedirectResponse()) + ->setURI('http://www.php.net/function.'.$this->name); + } + break; + case 'class': + if (class_exists($this->name) || + in_array($this->name, get_declared_interfaces())) { + if (id(new ReflectionClass($this->name))->isInternal()) { + return id(new AphrontRedirectResponse()) + ->setURI('http://www.php.net/class.'.$this->name); + } + } + break; } } }