From 6906de45c1d5edc38a14e9cbbed6337960b1ff0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thiemo=20M=C3=A4ttig?= Date: Mon, 7 Mar 2016 12:02:43 +0100 Subject: [PATCH] Fix @param and @return types on all PPFrame::getArgument methods This is about template parameters. They can be indexed by position (int) or name (string). The returned value is always a string, or false (bool) on failure. Change-Id: I565210ad485505281246ef2bb3086a675b905976 --- includes/parser/Preprocessor.php | 4 ++-- includes/parser/Preprocessor_DOM.php | 20 ++++++++++++++++++++ includes/parser/Preprocessor_Hash.php | 16 ++++++++-------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/includes/parser/Preprocessor.php b/includes/parser/Preprocessor.php index 368d79ef49..cc98abd5c0 100644 --- a/includes/parser/Preprocessor.php +++ b/includes/parser/Preprocessor.php @@ -260,8 +260,8 @@ interface PPFrame { /** * Get an argument to this frame by name - * @param string $name - * @return bool + * @param int|string $name + * @return string|bool */ public function getArgument( $name ); diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 79a66e05e8..4c94b2ae90 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -1462,6 +1462,10 @@ class PPFrame_DOM implements PPFrame { return true; } + /** + * @param int|string $name + * @return bool Always false in this implementation. + */ public function getArgument( $name ) { return false; } @@ -1646,6 +1650,10 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { return $arguments; } + /** + * @param int $index + * @return string|bool + */ public function getNumberedArgument( $index ) { if ( !isset( $this->numberedArgs[$index] ) ) { return false; @@ -1660,6 +1668,10 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { return $this->numberedExpansionCache[$index]; } + /** + * @param string $name + * @return string|bool + */ public function getNamedArgument( $name ) { if ( !isset( $this->namedArgs[$name] ) ) { return false; @@ -1672,6 +1684,10 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { return $this->namedExpansionCache[$name]; } + /** + * @param int|string $name + * @return string|bool + */ public function getArgument( $name ) { $text = $this->getNumberedArgument( $name ); if ( $text === false ) { @@ -1738,6 +1754,10 @@ class PPCustomFrame_DOM extends PPFrame_DOM { return !count( $this->args ); } + /** + * @param int|string $index + * @return string|bool + */ public function getArgument( $index ) { if ( !isset( $this->args[$index] ) ) { return false; diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 24baae43d5..f030ccac1c 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -1355,8 +1355,8 @@ class PPFrame_Hash implements PPFrame { } /** - * @param string $name - * @return bool + * @param int|string $name + * @return bool Always false in this implementation. */ public function getArgument( $name ) { return false; @@ -1549,7 +1549,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { /** * @param int $index - * @return array|bool + * @return string|bool */ public function getNumberedArgument( $index ) { if ( !isset( $this->numberedArgs[$index] ) ) { @@ -1567,7 +1567,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { /** * @param string $name - * @return bool + * @return string|bool */ public function getNamedArgument( $name ) { if ( !isset( $this->namedArgs[$name] ) ) { @@ -1582,8 +1582,8 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { } /** - * @param string $name - * @return array|bool + * @param int|string $name + * @return string|bool */ public function getArgument( $name ) { $text = $this->getNumberedArgument( $name ); @@ -1652,8 +1652,8 @@ class PPCustomFrame_Hash extends PPFrame_Hash { } /** - * @param int $index - * @return bool + * @param int|string $index + * @return string|bool */ public function getArgument( $index ) { if ( !isset( $this->args[$index] ) ) { -- 2.20.1