Improve and simplify typehint and type docs in VectorTemplate
* renderPortals() - Takes array only, enforce this with a type hint. * renderPortal() - Actually takes either array or string as $content, fix the type doc to match the code. * renderNavigation() - Simplify by removing support for non-array $elements, fixing one caller. This and other minor changes are tracked under T140664, which intends to reduce code complexity in Vector to (potentially) make it portable to an HTML template. Change-Id: Idc95d023a55c83450b041109745cfbcbcd04f580
This commit is contained in:
parent
57913d80b8
commit
56e566f351
|
@ -152,7 +152,7 @@ class VectorTemplate extends BaseTemplate {
|
||||||
<div id="mw-navigation">
|
<div id="mw-navigation">
|
||||||
<h2><?php $this->msg( 'navigation-heading' ) ?></h2>
|
<h2><?php $this->msg( 'navigation-heading' ) ?></h2>
|
||||||
<div id="mw-head">
|
<div id="mw-head">
|
||||||
<?php $this->renderNavigation( 'PERSONAL' ); ?>
|
<?php $this->renderNavigation( [ 'PERSONAL' ] ); ?>
|
||||||
<div id="left-navigation">
|
<div id="left-navigation">
|
||||||
<?php $this->renderNavigation( [ 'NAMESPACES', 'VARIANTS' ] ); ?>
|
<?php $this->renderNavigation( [ 'NAMESPACES', 'VARIANTS' ] ); ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -221,7 +221,7 @@ class VectorTemplate extends BaseTemplate {
|
||||||
*
|
*
|
||||||
* @param array $portals
|
* @param array $portals
|
||||||
*/
|
*/
|
||||||
protected function renderPortals( $portals ) {
|
protected function renderPortals( array $portals ) {
|
||||||
// Force the rendering of the following portals
|
// Force the rendering of the following portals
|
||||||
if ( !isset( $portals['SEARCH'] ) ) {
|
if ( !isset( $portals['SEARCH'] ) ) {
|
||||||
$portals['SEARCH'] = true;
|
$portals['SEARCH'] = true;
|
||||||
|
@ -262,7 +262,7 @@ class VectorTemplate extends BaseTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $content
|
* @param array|string $content
|
||||||
* @param null|string $msg
|
* @param null|string $msg
|
||||||
* @param null|string|array $hook
|
* @param null|string|array $hook
|
||||||
*/
|
*/
|
||||||
|
@ -316,12 +316,7 @@ class VectorTemplate extends BaseTemplate {
|
||||||
*
|
*
|
||||||
* @param array $elements
|
* @param array $elements
|
||||||
*/
|
*/
|
||||||
protected function renderNavigation( $elements ) {
|
protected function renderNavigation( array $elements ) {
|
||||||
// If only one element was given, wrap it in an array, allowing more
|
|
||||||
// flexible arguments
|
|
||||||
if ( !is_array( $elements ) ) {
|
|
||||||
$elements = [ $elements ];
|
|
||||||
}
|
|
||||||
// Render elements
|
// Render elements
|
||||||
foreach ( $elements as $name => $element ) {
|
foreach ( $elements as $name => $element ) {
|
||||||
switch ( $element ) {
|
switch ( $element ) {
|
||||||
|
|
Loading…
Reference in New Issue