Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/248872

Change subject: Add array type hints and more specific documentation
......................................................................

Add array type hints and more specific documentation

The two public functions ref() and references() are called from
Parser::extensionSubstitution(). Everything else is derived from that.

Change-Id: Ib9bb37ac0303f0e90149f5b1c4f4aa3bcf08b957
---
M Cite_body.php
1 file changed, 26 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cite 
refs/changes/72/248872/1

diff --git a/Cite_body.php b/Cite_body.php
index 8c5e808..151c608 100644
--- a/Cite_body.php
+++ b/Cite_body.php
@@ -158,14 +158,14 @@
        /**
         * Callback function for <ref>
         *
-        * @param $str string Input
-        * @param $argv array Arguments
+        * @param string|null $str Raw content of the <ref> tag.
+        * @param string[] $argv Arguments
         * @param $parser Parser
         * @param $frame PPFrame
         *
         * @return string
         */
-       function ref( $str, $argv, $parser, $frame ) {
+       function ref( $str, array $argv, Parser $parser, PPFrame $frame ) {
                if ( $this->mInCite ) {
                        return htmlspecialchars( "<ref>$str</ref>" );
                }
@@ -189,7 +189,7 @@
        }
 
        /**
-        * @param $str string Input
+        * @param string|null $str Raw content of the <ref> tag.
         * @param $argv array Arguments
         * @param $parser Parser
         * @param $default_group string
@@ -323,11 +323,11 @@
         *  "follow" : If the current reference is the continuation of another, 
key of that reference.
         *
         *
-        * @param $argv array The argument vector
+        * @param string[] $argv The argument vector
         * @return mixed false on invalid input, a string on valid
         *               input and null on no input
         */
-       function refArg( $argv ) {
+       function refArg( array $argv ) {
                global $wgAllowCiteGroups;
                $cnt = count( $argv );
                $group = null;
@@ -382,9 +382,9 @@
         *
         * @param $str string Input from the <ref> tag
         * @param $key mixed Argument to the <ref> tag as returned by 
$this->refArg()
-        * @param $group
-        * @param $follow
-        * @param $call
+        * @param string $group
+        * @param string|null $follow
+        * @param array $call
         *
         * @return string
         */
@@ -407,11 +407,12 @@
                                                break;
                                        }
                                }
-                               array_splice( $this->mRefs[$group], $k, 0,
-                                       array( array( 'count' => - 1,
-                                               'text' => $str,
-                                               'key' => ++$this->mOutCnt ,
-                                               'follow' => $follow ) ) );
+                               array_splice( $this->mRefs[$group], $k, 0, 
array( array(
+                                       'count' => -1,
+                                       'text' => $str,
+                                       'key' => ++$this->mOutCnt,
+                                       'follow' => $follow
+                               ) ) );
                                array_splice( $this->mRefCallStack, $k, 0,
                                        array( array( 'new', $call, $str, $key, 
$group, $this->mOutCnt ) ) );
                        }
@@ -422,7 +423,11 @@
                if ( $key === null ) {
                        // No key
                        // $this->mRefs[$group][] = $str;
-                       $this->mRefs[$group][] = array( 'count' => - 1, 'text' 
=> $str, 'key' => ++$this->mOutCnt );
+                       $this->mRefs[$group][] = array(
+                               'count' => -1,
+                               'text' => $str,
+                               'key' => ++$this->mOutCnt
+                       );
                        $this->mRefCallStack[] = array( 'new', $call, $str, 
$key, $group, $this->mOutCnt );
 
                        return $this->linkRef( $group, $this->mOutCnt );
@@ -544,14 +549,14 @@
        /**
         * Callback function for <references>
         *
-        * @param $str string Input
-        * @param $argv array Arguments
+        * @param string|null $str Raw content of the <references> tag.
+        * @param string[] $argv Arguments
         * @param $parser Parser
         * @param $frame PPFrame
         *
         * @return string
         */
-       function references( $str, $argv, $parser, $frame ) {
+       function references( $str, array $argv, Parser $parser, PPFrame $frame 
) {
                if ( $this->mInCite || $this->mInReferences ) {
                        if ( is_null( $str ) ) {
                                return htmlspecialchars( "<references/>" );
@@ -569,13 +574,13 @@
        }
 
        /**
-        * @param $str string
-        * @param $argv array
+        * @param string|null $str Raw content of the <references> tag.
+        * @param string[] $argv
         * @param $parser Parser
         * @param $group string
         * @return string
         */
-       function guardedReferences( $str, $argv, $parser, $group = 
self::DEFAULT_GROUP ) {
+       function guardedReferences( $str, array $argv, Parser $parser, $group = 
self::DEFAULT_GROUP ) {
                global $wgAllowCiteGroups;
 
                $this->mParser = $parser;

-- 
To view, visit https://gerrit.wikimedia.org/r/248872
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9bb37ac0303f0e90149f5b1c4f4aa3bcf08b957
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cite
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to