9 * This source file is subject to the new BSD license that is bundled
10 * with this package in the file LICENSE.
11 * It is also available through the world-wide-web at this URL:
12 * http://phergie.org/license
15 * @package Phergie_Plugin_Php
16 * @author Phergie Development Team <team@phergie.org>
17 * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
18 * @license http://phergie.org/license New BSD License
19 * @link http://pear.phergie.org/package/Phergie_Plugin_Php
23 * Returns information on PHP functions as requested.
26 * @package Phergie_Plugin_Php
27 * @author Phergie Development Team <team@phergie.org>
28 * @license http://phergie.org/license New BSD License
29 * @link http://pear.phergie.org/package/Phergie_Plugin_Php
31 * @uses extension pdo_sqlite
32 * @uses Phergie_Plugin_Command pear.phergie.org
34 class Phergie_Plugin_Php extends Phergie_Plugin_Abstract
39 * @var Phergie_Plugin_Php_Source
44 * Check for dependencies.
48 public function onLoad()
50 // @todo find a way to move this to Phergie_Plugin_Php_Source_Local
51 if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) {
52 $this->fail('PDO and pdo_sqlite extensions must be installed');
55 $this->getPluginHandler()->getPlugin('Command');
59 * Initializes the data source.
63 public function onConnect()
65 $this->source = new Phergie_Plugin_Php_Source_Local;
69 * Searches the data source for the requested function.
71 * @param string $functionName Name of the function to search for
75 public function onCommandPhp($functionName)
77 $nick = $this->event->getNick();
78 if ($function = $this->source->findFunction($functionName)) {
79 $msg = $nick . ': ' . $function['description'];
80 $this->doPrivmsg($this->event->getSource(), $msg);
82 $msg = 'Search for function ' . $functionName . ' returned no results.';
83 $this->doNotice($nick, $msg);