Comment and typing improvements

To make the StatusNet::addPlugin() accept only arrays,
the lib/default.php had to be changed because all plugins
had 'null' as default value instead of an array.
This commit is contained in:
Mikael Nordfeldth 2013-11-18 20:43:00 +01:00
parent 06b068d43b
commit c942bdcb43
4 changed files with 16 additions and 16 deletions

View File

@ -298,15 +298,15 @@ $default =
'StrictTransportSecurity' => null,
),
'default' => array(
'Activity' => null,
'Bookmark' => null,
'ClientSideShorten' => null,
'Event' => null,
'OpenID' => null,
'Poll' => null,
'QnA' => null,
'SearchSub' => null,
'TagSub' => null,
'Activity' => array(),
'Bookmark' => array(),
'ClientSideShorten' => array(),
'Event' => array(),
'OpenID' => array(),
'Poll' => array(),
'QnA' => array(),
'SearchSub' => array(),
'TagSub' => array(),
),
'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories
'server' => null,

View File

@ -95,7 +95,7 @@ require_once(INSTALLDIR.'/lib/language.php');
require_once(INSTALLDIR.'/lib/event.php');
require_once(INSTALLDIR.'/lib/plugin.php');
function addPlugin($name, $attrs = null)
function addPlugin($name, array $attrs=array())
{
return StatusNet::addPlugin($name, $attrs);
}

View File

@ -44,7 +44,7 @@ class StatusNet
*
* @throws ServerException if plugin can't be found
*/
public static function addPlugin($name, $attrs = null)
public static function addPlugin($name, array $attrs=array())
{
$name = ucfirst($name);
@ -78,12 +78,12 @@ class StatusNet
}
}
// Doesn't this $inst risk being garbage collected or something?
// TODO: put into a static array that makes sure $inst isn't lost.
$inst = new $pluginclass();
if (!empty($attrs)) {
foreach ($attrs as $aname => $avalue) {
$inst->$aname = $avalue;
}
}
// Record activated plugins for later display/config dump
self::$plugins[$name] = $attrs;

View File

@ -24,7 +24,7 @@ require_once INSTALLDIR.'/scripts/commandline.inc';
foreach (StatusNet::getActivePlugins() as $plugin=>$args) {
echo "$plugin: ";
if ($args === null) {
if (empty($args)) {
echo "(no args)\n";
} else {
foreach ($args as $arg => $val) {