X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSiteConfiguration.php;h=b8775440994f7525f2d6a319f7a5957c304c27d6;hb=296c6b39e5e29dcf5cec0e872d1cddc513ab5fda;hp=2f28e7b7f5112abd900dd59967535b06bfe86d37;hpb=ed945112a8640fcaefa0128456602893294aee31;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index 2f28e7b7f5..b877544099 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -108,7 +108,7 @@ * extract( $globals ); * @endcode * - * TODO: give examples for, + * @todo Give examples for, * suffixes: * $conf->suffixes = array( 'wiki' ); * localVHosts @@ -176,7 +176,9 @@ class SiteConfiguration { * @param array $wikiTags The tags assigned to the wiki. * @return mixed The value of the setting requested. */ - public function get( $settingName, $wiki, $suffix = null, $params = array(), $wikiTags = array() ) { + public function get( $settingName, $wiki, $suffix = null, $params = array(), + $wikiTags = array() + ) { $params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags ); return $this->getSetting( $settingName, $wiki, $params ); } @@ -189,7 +191,7 @@ class SiteConfiguration { * @param array $params Array of parameters. * @return mixed The value of the setting requested. */ - protected function getSetting( $settingName, $wiki, /*array*/ $params ) { + protected function getSetting( $settingName, $wiki, array $params ) { $retval = null; if ( array_key_exists( $settingName, $this->settings ) ) { $thisSetting =& $this->settings[$settingName]; @@ -205,14 +207,14 @@ class SiteConfiguration { // Do tag settings foreach ( $params['tags'] as $tag ) { if ( array_key_exists( $tag, $thisSetting ) ) { - if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$tag] ) ) { + if ( is_array( $retval ) && is_array( $thisSetting[$tag] ) ) { $retval = self::arrayMerge( $retval, $thisSetting[$tag] ); } else { $retval = $thisSetting[$tag]; } break 2; } elseif ( array_key_exists( "+$tag", $thisSetting ) && is_array( $thisSetting["+$tag"] ) ) { - if ( !isset( $retval ) ) { + if ( $retval === null ) { $retval = array(); } $retval = self::arrayMerge( $retval, $thisSetting["+$tag"] ); @@ -222,14 +224,16 @@ class SiteConfiguration { $suffix = $params['suffix']; if ( !is_null( $suffix ) ) { if ( array_key_exists( $suffix, $thisSetting ) ) { - if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) { + if ( is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) { $retval = self::arrayMerge( $retval, $thisSetting[$suffix] ); } else { $retval = $thisSetting[$suffix]; } break; - } elseif ( array_key_exists( "+$suffix", $thisSetting ) && is_array( $thisSetting["+$suffix"] ) ) { - if ( !isset( $retval ) ) { + } elseif ( array_key_exists( "+$suffix", $thisSetting ) + && is_array( $thisSetting["+$suffix"] ) + ) { + if ( $retval === null ) { $retval = array(); } $retval = self::arrayMerge( $retval, $thisSetting["+$suffix"] ); @@ -338,7 +342,9 @@ class SiteConfiguration { * @param array $params List of parameters. $.'key' is replaced by $value in all returned data. * @param array $wikiTags The tags assigned to the wiki. */ - public function extractVar( $setting, $wiki, $suffix, &$var, $params = array(), $wikiTags = array() ) { + public function extractVar( $setting, $wiki, $suffix, &$var, + $params = array(), $wikiTags = array() + ) { $value = $this->get( $setting, $wiki, $suffix, $params, $wikiTags ); if ( !is_null( $value ) ) { $var = $value; @@ -353,7 +359,9 @@ class SiteConfiguration { * @param array $params List of parameters. $.'key' is replaced by $value in all returned data. * @param array $wikiTags The tags assigned to the wiki. */ - public function extractGlobal( $setting, $wiki, $suffix = null, $params = array(), $wikiTags = array() ) { + public function extractGlobal( $setting, $wiki, $suffix = null, + $params = array(), $wikiTags = array() + ) { $params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags ); $this->extractGlobalSetting( $setting, $wiki, $params ); } @@ -386,7 +394,9 @@ class SiteConfiguration { * @param array $params List of parameters. $.'key' is replaced by $value in all returned data. * @param array $wikiTags The tags assigned to the wiki. */ - public function extractAllGlobals( $wiki, $suffix = null, $params = array(), $wikiTags = array() ) { + public function extractAllGlobals( $wiki, $suffix = null, $params = array(), + $wikiTags = array() + ) { $params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags ); foreach ( $this->settings as $varName => $setting ) { $this->extractGlobalSetting( $varName, $wiki, $params ); @@ -440,7 +450,7 @@ class SiteConfiguration { * @param array $wikiTags The tags assigned to the wiki. * @return array */ - protected function mergeParams( $wiki, $suffix, /*array*/ $params, /*array*/ $wikiTags ) { + protected function mergeParams( $wiki, $suffix, array $params, array $wikiTags ) { $ret = $this->getWikiParams( $wiki ); if ( is_null( $ret['suffix'] ) ) { @@ -574,12 +584,14 @@ class SiteConfiguration { */ static function arrayMerge( $array1/* ... */ ) { $out = $array1; - for ( $i = 1; $i < func_num_args(); $i++ ) { + $argsCount = func_num_args(); + for ( $i = 1; $i < $argsCount; $i++ ) { foreach ( func_get_arg( $i ) as $key => $value ) { if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) { $out[$key] = self::arrayMerge( $out[$key], $value ); } elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) { - // Values that evaluate to true given precedence, for the primary purpose of merging permissions arrays. + // Values that evaluate to true given precedence, for the + // primary purpose of merging permissions arrays. $out[$key] = $value; } elseif ( is_numeric( $key ) ) { $out[] = $value;