From c942bdcb4321549879a0f3f5d2ab514d33b90996 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 18 Nov 2013 20:43:00 +0100 Subject: [PATCH] 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. --- lib/default.php | 18 +++++++++--------- lib/framework.php | 2 +- lib/statusnet.php | 10 +++++----- scripts/showplugins.php | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/default.php b/lib/default.php index 55ef65e81f..005a3683d8 100644 --- a/lib/default.php +++ b/lib/default.php @@ -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, diff --git a/lib/framework.php b/lib/framework.php index 3ef76ea4b5..76ba549098 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -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); } diff --git a/lib/statusnet.php b/lib/statusnet.php index cf2069c1a6..e596dd96d1 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -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,11 +78,11 @@ 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; - } + foreach ($attrs as $aname => $avalue) { + $inst->$aname = $avalue; } // Record activated plugins for later display/config dump diff --git a/scripts/showplugins.php b/scripts/showplugins.php index 3c03646227..e79b4e7224 100755 --- a/scripts/showplugins.php +++ b/scripts/showplugins.php @@ -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) {