r103452 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103451‎ | r103452 | r103453 >
Date:10:49, 17 November 2011
Author:questpc
Status:deferred
Tags:
Comment:
Remove the rest of object references via \&$. Do not create fake instance of qp_PollStore in Special:Pollresults. Correctly apply updated question definitions into DB. Array type hinting.
Modified paths:
  • /trunk/extensions/QPoll/ctrl/poll/qp_abstractpoll.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/poll/qp_poll.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/poll/qp_pollstats.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/qp_interpresult.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/question/qp_abstractquestion.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/question/qp_questionstats.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/question/qp_stubquestion.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/question/qp_textquestion.php (modified) (history)
  • /trunk/extensions/QPoll/includes/qp_functionshook.php (modified) (history)
  • /trunk/extensions/QPoll/includes/qp_renderer.php (modified) (history)
  • /trunk/extensions/QPoll/includes/qp_xlswriter.php (modified) (history)
  • /trunk/extensions/QPoll/interpretation/qp_eval.php (modified) (history)
  • /trunk/extensions/QPoll/interpretation/qp_interpret.php (modified) (history)
  • /trunk/extensions/QPoll/maintenance/qp_schemaupdater.php (modified) (history)
  • /trunk/extensions/QPoll/model/cache/qp_pollcache.php (modified) (history)
  • /trunk/extensions/QPoll/model/qp_pollstore.php (modified) (history)
  • /trunk/extensions/QPoll/model/qp_question_collection.php (modified) (history)
  • /trunk/extensions/QPoll/model/qp_questiondata.php (modified) (history)
  • /trunk/extensions/QPoll/qp_user.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_results.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_special.php (modified) (history)
  • /trunk/extensions/QPoll/view/proposal/qp_tabularquestionproposalview.php (modified) (history)
  • /trunk/extensions/QPoll/view/proposal/qp_textquestionproposalview.php (modified) (history)
  • /trunk/extensions/QPoll/view/qp_abstractview.php (modified) (history)
  • /trunk/extensions/QPoll/view/qp_interpresultview.php (modified) (history)
  • /trunk/extensions/QPoll/view/question/qp_stubquestionview.php (modified) (history)
  • /trunk/extensions/QPoll/view/question/qp_tabularquestionview.php (modified) (history)
  • /trunk/extensions/QPoll/view/question/qp_textquestionview.php (modified) (history)
  • /trunk/extensions/QPoll/view/results/qp_questiondataresults.php (modified) (history)
  • /trunk/extensions/QPoll/view/results/qp_textquestiondataresults.php (modified) (history)
  • /trunk/extensions/QPoll/view/xls/qp_xlspoll.php (modified) (history)
  • /trunk/extensions/QPoll/view/xls/qp_xlstabularquestion.php (modified) (history)
  • /trunk/extensions/QPoll/view/xls/qp_xlstextquestion.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/maintenance/qp_schemaupdater.php
@@ -123,7 +123,7 @@
124124 * @param $tableset array list of DB tables in set
125125 * @return array with names of non-existing tables in specified list
126126 */
127 - private static function tablesExists( $tableset ) {
 127+ private static function tablesExists( array $tableset ) {
128128 $db = & wfGetDB( DB_MASTER );
129129 $tablesNotFound = array();
130130 foreach ( $tableset as &$table ) {
Index: trunk/extensions/QPoll/model/cache/qp_pollcache.php
@@ -284,7 +284,7 @@
285285 $this->updateFromPollStore();
286286 if ( count( $this->replace ) < 1 ) {
287287 # this cannot happen here; however it can happen in ancestor classes
288 - throw new Exception( "zero rows replace in " . __METHOD__ );
 288+ throw new MWException( "zero rows replace in " . __METHOD__ );
289289 }
290290 $replaceRows = ( $curr_cache_rows = $wgMemc->get( $this->getMemcKey() ) ) === false ||
291291 serialize( $curr_cache_rows ) !== serialize( $this->memc_rows );
Index: trunk/extensions/QPoll/model/qp_questiondata.php
@@ -64,14 +64,7 @@
6565 return;
6666 } elseif ( $argv instanceof qp_StubQuestion ) {
6767 # create question data from the already existing question
68 - $this->question_id = $argv->mQuestionId;
69 - $this->type = $argv->mType;
70 - $this->CommonQuestion = $argv->mCommonQuestion;
71 - $this->Categories = $argv->mCategories;
72 - $this->CategorySpans = $argv->mCategorySpans;
73 - $this->ProposalText = $argv->mProposalText;
74 - $this->ProposalNames = $argv->mProposalNames;
75 - $this->setQuestionAnswer( $argv );
 68+ $this->applyQuestion( $argv );
7669 return;
7770 }
7871 throw new MWException( "argv is neither an array nor instance of qp_QuestionData in " . __METHOD__ );
@@ -114,7 +107,7 @@
115108 *
116109 * Used to reject previous vote in case the header is incompatble.
117110 */
118 - function isCompatible( &$question ) {
 111+ function isCompatible( qp_StubQuestion $question ) {
119112 if ( $question->mType != $this->type ) {
120113 return false;
121114 }
@@ -206,7 +199,14 @@
207200 return ( $name !== '' ) ? ":|{$name}|" : '';
208201 }
209202
210 - public function setQuestionAnswer( qp_StubQuestion $question ) {
 203+ public function applyQuestion( qp_StubQuestion $question ) {
 204+ $this->question_id = $question->mQuestionId;
 205+ $this->type = $question->mType;
 206+ $this->CommonQuestion = $question->mCommonQuestion;
 207+ $this->Categories = $question->mCategories;
 208+ $this->CategorySpans = $question->mCategorySpans;
 209+ $this->ProposalText = $question->mProposalText;
 210+ $this->ProposalNames = $question->mProposalNames;
211211 $this->ProposalCategoryId = $question->mProposalCategoryId;
212212 $this->ProposalCategoryText = $question->mProposalCategoryText;
213213 }
Index: trunk/extensions/QPoll/model/qp_question_collection.php
@@ -65,7 +65,7 @@
6666 * placed in $except. ($except must therefore be an array)
6767 * function returns false if $except holds all values between $min and $max.
6868 */
69 - function rand_except( $min, $max, $except ) {
 69+ function rand_except( $min, $max, array $except ) {
7070 # first sort array values
7171 sort( $except, SORT_NUMERIC );
7272 # calculate average gap between except-values
@@ -112,7 +112,7 @@
113113
114114 function setUsedQuestions( $randomQuestions ) {
115115 if ( !is_array( $randomQuestions ) ) {
116 - foreach ( $this->questions as $qidx => &$question ) {
 116+ foreach ( $this->questions as $qidx => $question ) {
117117 $question->usedId = $question->mQuestionId;
118118 }
119119 return;
@@ -121,7 +121,7 @@
122122 $this->usedQuestions = array();
123123 # questions keys start from 1
124124 $usedId = 1;
125 - foreach ( $this->questions as $qidx => &$question ) {
 125+ foreach ( $this->questions as $qidx => $question ) {
126126 if ( in_array( $qidx, $randomQuestions, true ) ) {
127127 # usedQuestions keys start from 0
128128 $this->usedQuestions[] = $qidx;
@@ -149,7 +149,7 @@
150150
151151 function usedCount() {
152152 $used = 0;
153 - foreach ( $this->questions as &$question ) {
 153+ foreach ( $this->questions as $question ) {
154154 if ( $question->usedId !== false ) {
155155 $used++;
156156 }
Index: trunk/extensions/QPoll/model/qp_pollstore.php
@@ -86,38 +86,39 @@
8787 * @param $argv['from'] indicates type of construction, other elements of $argv
8888 * vary according to the value of 'from'
8989 */
90 - function __construct( $argv = null ) {
 90+ function __construct( array $argv ) {
9191 $this->interpResult = new qp_InterpResult();
9292 # set poll store of poll descriptions cache and all it's ancestors
9393 qp_PollCache::setStore( $this );
94 - if ( is_array( $argv ) && array_key_exists( "from", $argv ) ) {
 94+ $from = 'null';
 95+ if ( array_key_exists( 'from', $argv ) ) {
 96+ $from = $argv['from'];
9597 $this->Questions = array();
9698 $this->mCompletedPostData = 'NA';
9799 $this->pid = null;
98100 $is_post = false;
99 - switch ( $argv[ 'from' ] ) {
100 - case 'poll_post' :
101 - $is_post = true;
102 - case 'poll_get' :
103 - $this->createFromTagData( $argv, $is_post );
104 - break;
105 - case 'pid' :
106 - if ( array_key_exists( 'pid', $argv ) ) {
107 - $pid = intval( $argv[ 'pid' ] );
108 - $this->createFromPid( $pid );
109 - }
110 - break;
111 - default :
112 - throw new MWException( 'Unknown value of "from" parameter: ' . $argv[ 'from' ] . ' in ' . __METHOD__ );
 101+ switch ( $from ) {
 102+ case 'poll_post' :
 103+ $is_post = true;
 104+ case 'poll_get' :
 105+ $this->createFromTagData( $argv, $is_post );
 106+ return;
 107+ case 'pid' :
 108+ if ( array_key_exists( 'pid', $argv ) ) {
 109+ $pid = intval( $argv[ 'pid' ] );
 110+ $this->createFromPid( $pid );
 111+ }
 112+ return;
113113 }
114114 }
 115+ throw new MWException( 'Unknown value of "from" parameter: ' . $from . ' in ' . __METHOD__ );
115116 }
116117
117118 /**
118119 * Creates new poll from data available in qpoll tag attributes.
119120 * Usually that is HTTP GET / POST operation.
120121 */
121 - function createFromTagData( &$argv, $is_post ) {
 122+ function createFromTagData( array &$argv, $is_post ) {
122123 global $wgParser;
123124 if ( array_key_exists( 'title', $argv ) ) {
124125 $title = $argv[ 'title' ];
@@ -824,7 +825,7 @@
825826 * Get username by uid
826827 * @param $uid integer qpoll user id
827828 */
828 - function getUserName( $uid ) {
 829+ static function getUserName( $uid ) {
829830 $db = wfGetDB( DB_MASTER );
830831 if ( $uid !== null ) {
831832 $res = $db->select(
@@ -908,13 +909,14 @@
909910 * @param $question qp_StubQuestion
910911 * instance of question which has current user vote
911912 */
912 - public function setQuestionAnswer( qp_StubQuestion $question ) {
 913+ public function setQuestion( qp_StubQuestion $question ) {
913914 if ( $this->questionExists( $question->mQuestionId ) ) {
914915 # question data already exists, poll structure was stored during previous
915916 # submission.
916917 # question, category and proposal descriptions are already loaded into
917918 # $this->Questions[$question->mQuestionId] by $this->loadQuestions()
918 - $this->Questions[$question->mQuestionId]->setQuestionAnswer( $question );
 919+ # but might have pending update, if the source of the poll was modified
 920+ $this->Questions[$question->mQuestionId]->applyQuestion( $question );
919921 } else {
920922 # create new question data from scratch (first submission)
921923 $this->Questions[$question->mQuestionId] = qp_QuestionData::factory( $question );
Index: trunk/extensions/QPoll/specials/qp_special.php
@@ -51,7 +51,12 @@
5252 parent::__construct( $name, $restriction, $listed, $function, $file, $includable );
5353 }
5454
55 - function qpLink( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) {
 55+ function qpLink(
 56+ $target,
 57+ $text = null,
 58+ array $customAttribs = array(),
 59+ array $query = array(),
 60+ array $options = array() ) {
5661 return self::$linker->link( $target, $text, $customAttribs, $query, $options );
5762 }
5863
Index: trunk/extensions/QPoll/specials/qp_results.php
@@ -203,7 +203,7 @@
204204 return '';
205205 }
206206 $pollStore->loadQuestions();
207 - $userName = $pollStore->getUserName( $uid );
 207+ $userName = qp_PollStore::getUserName( $uid );
208208 if ( $userName === false ) {
209209 return '';
210210 }
@@ -221,7 +221,7 @@
222222 $headerTags = $this->getAnswerHeader( $pollStore );
223223 $output .= qp_Renderer::renderTagArray( $headerTags );
224224 unset( $headerTags );
225 - foreach ( $pollStore->Questions as &$qdata ) {
 225+ foreach ( $pollStore->Questions as $qdata ) {
226226 if ( $pollStore->isUsedQuestion( $qdata->question_id ) ) {
227227 $output .= "<br />\n<b>" . $qdata->question_id . ".</b> " . qp_Setup::entities( $qdata->CommonQuestion ) . "<br />\n";
228228 $qview = $qdata->getView();
@@ -251,7 +251,7 @@
252252 $output .= $this->qpLink( $this->getTitle(), wfMsg( 'qp_export_to_xls' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'stats_xls', 'id' => $pid ) ) . "<br />\n";
253253 $output .= $this->qpLink( $this->getTitle(), wfMsg( 'qp_voices_to_xls' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'voices_xls', 'id' => $pid ) ) . "<br />\n";
254254 $output .= $this->qpLink( $this->getTitle(), wfMsg( 'qp_interpretation_results_to_xls' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'interpretation_xls', 'id' => $pid ) ) . "<br />\n";
255 - foreach ( $pollStore->Questions as &$qdata ) {
 255+ foreach ( $pollStore->Questions as $qdata ) {
256256 $qview = $qdata->getView();
257257 $output .= $qview->displayQuestionStats( $this, $pid );
258258 }
@@ -415,9 +415,7 @@
416416
417417 function getPageHeader() {
418418 global $wgLang, $wgContLang;
419 - # fake pollStore to get username by uid: avoid to use this trick as much as possible
420 - $pollStore = new qp_PollStore();
421 - $userName = $pollStore->getUserName( $this->uid );
 419+ $userName = qp_PollStore::getUserName( $this->uid );
422420 $db = wfGetDB( DB_SLAVE );
423421 $res = $db->select(
424422 'qp_users_polls',
@@ -654,24 +652,24 @@
655653 # 'parentheses' are unavailable in MW 1.14.x
656654 $head[] = wfMsg( 'qp_parentheses', $goto_link ) . '<br />';
657655 $ques_found = false;
658 - foreach ( $pollStore->Questions as &$ques ) {
659 - if ( $ques->question_id == $this->question_id ) {
 656+ foreach ( $pollStore->Questions as $qdata ) {
 657+ if ( $qdata->question_id == $this->question_id ) {
660658 $ques_found = true;
661659 break;
662660 }
663661 }
664662 if ( $ques_found ) {
665 - $qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, qp_Setup::entities( $ques->CommonQuestion ) );
666 - if ( array_key_exists( $this->cat_id, $ques->Categories ) ) {
667 - $categ = &$ques->Categories[ $this->cat_id ];
668 - $proptext = $ques->ProposalText[ $this->proposal_id ];
 663+ $qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, qp_Setup::entities( $qdata->CommonQuestion ) );
 664+ if ( array_key_exists( $this->cat_id, $qdata->Categories ) ) {
 665+ $categ = &$qdata->Categories[ $this->cat_id ];
 666+ $proptext = $qdata->ProposalText[ $this->proposal_id ];
669667 $cat_name = $categ['name'];
670668 if ( array_key_exists( 'spanId', $categ ) ) {
671 - $cat_name = wfMsg( 'qp_full_category_name', $cat_name, $ques->CategorySpans[ $categ['spanId'] ]['name'] );
 669+ $cat_name = wfMsg( 'qp_full_category_name', $cat_name, $qdata->CategorySpans[ $categ['spanId'] ]['name'] );
672670 }
673671 $qpa = wfMsg( 'qp_header_line_qucl',
674672 $this->question_id,
675 - qp_Setup::entities( $ques->CommonQuestion ),
 673+ qp_Setup::entities( $qdata->CommonQuestion ),
676674 qp_Setup::entities( $proptext ),
677675 qp_Setup::entities( $cat_name ) ) . '<br />';
678676 $head[] = array( '__tag' => 'div', 'class' => 'head', 'style' => 'padding-left:2em;', 0 => $qpa );
Index: trunk/extensions/QPoll/ctrl/poll/qp_abstractpoll.php
@@ -99,7 +99,7 @@
100100 *
101101 * @public
102102 */
103 - function __construct( $argv, qp_AbstractPollView $view ) {
 103+ function __construct( array $argv, qp_AbstractPollView $view ) {
104104 global $wgLanguageCode;
105105 $this->mResponse = qp_Setup::$request->response();
106106 # Determine which messages will be used, according to the language.
@@ -250,7 +250,7 @@
251251 * @modifies $paramkeys array key is attribute regexp, value is the value of attribute
252252 * @return string the value of question's type attribute
253253 */
254 - function getQuestionAttributes( $attr_str, &$paramkeys ) {
 254+ function getQuestionAttributes( $attr_str, array &$paramkeys ) {
255255 $paramkeys = qp_Setup::getXmlLikeAttributes( $attr_str, $this->questionAttributeKeys );
256256 # apply default questions attributes from poll definition, if there is any
257257 foreach ( $this->defaultQuestionAttributes as $attr => $val ) {
Index: trunk/extensions/QPoll/ctrl/poll/qp_pollstats.php
@@ -42,7 +42,7 @@
4343 */
4444 class qp_PollStats extends qp_AbstractPoll {
4545
46 - function __construct( $argv, qp_PollStatsView $view ) {
 46+ function __construct( array $argv, qp_PollStatsView $view ) {
4747 parent::__construct( $argv, $view );
4848 $this->pollAddr = trim( $argv['address'] );
4949 }
@@ -99,7 +99,7 @@
100100 array_unshift( $unparsedAttributes, null );
101101 unset( $unparsedAttributes[0] );
102102 # first pass: parse the headers
103 - foreach ( $this->pollStore->Questions as &$qdata ) {
 103+ foreach ( $this->pollStore->Questions as $qdata ) {
104104 $question = new qp_QuestionStats(
105105 $this,
106106 qp_QuestionStatsView::newFromBaseView( $this->view ),
@@ -148,7 +148,7 @@
149149
150150 # populate the question with data and build it's HTML representation
151151 # returns HTML representation of the question
152 - function parseStats( qp_QuestionStats &$question ) {
 152+ function parseStats( qp_QuestionStats $question ) {
153153 # parse the question body
154154 if ( $question->getQuestionAnswer( $this->pollStore ) ) {
155155 $question->statsParseBody();
Index: trunk/extensions/QPoll/ctrl/poll/qp_poll.php
@@ -54,7 +54,7 @@
5555 # maximal count of attepts of answer submission ( < 1 for infinite )
5656 var $maxAttempts = 0;
5757
58 - function __construct( $argv, qp_PollView $view ) {
 58+ function __construct( array $argv, qp_PollView $view ) {
5959 parent::__construct( $argv, $view );
6060 # dependance attr
6161 if ( array_key_exists( 'dependance', $argv ) ) {
@@ -374,8 +374,9 @@
375375 /**
376376 * Parse question main header (common question and XML attributes)
377377 * initializes common question and question type/subtype
378 - * @param $input the question's header in QPoll syntax
379 - * @return an instance of question that matches the header attributes
 378+ * @param $header string
 379+ * the question's header in QPoll syntax
 380+ * @return instance of question that matches the header attributes
380381 */
381382 function parseMainHeader( $header ) {
382383 # split common question and question attributes from the header
@@ -473,7 +474,7 @@
474475 if ( $this->mBeingCorrected ) {
475476 if ( $question->getState() == '' ) {
476477 # question is OK, store it into pollStore
477 - $this->pollStore->setQuestionAnswer( $question );
 478+ $this->pollStore->setQuestion( $question );
478479 } else {
479480 # http post: not every proposals were answered: do not update DB
480481 $this->pollStore->stateIncomplete();
Index: trunk/extensions/QPoll/ctrl/qp_interpresult.php
@@ -139,13 +139,16 @@
140140
141141 /**
142142 * Build a projection of associative array tree to 2nd dimensional array
143 - * @modifies $strucTable array destination 2nd dimensional array
144 - * (see description in $this->getStructuredAnswerTable);
145 - * @param $structured array current node of associative array tree
146 - * @param $level_header string current "folder-like" prefix of
147 - * structured answer nested key (levels are separated with " / ")
 143+ * @modifies $strucTable array
 144+ * destination 2nd dimensional array;
 145+ * see description in $this->getStructuredAnswerTable();
 146+ * @param $structured mixed
 147+ * array / scalar current node of associative array tree
 148+ * @param $level_header string
 149+ * current "folder-like" prefix of structured answer nested key
 150+ * (levels are separated with " / ")
148151 */
149 - function buildStructuredTable( &$strucTable, &$structured, $level_header = '' ) {
 152+ function buildStructuredTable( array &$strucTable, &$structured, $level_header = '' ) {
150153 $keys = array();
151154 $vals = array();
152155 if ( is_array( $structured ) ) {
Index: trunk/extensions/QPoll/ctrl/question/qp_abstractquestion.php
@@ -85,7 +85,7 @@
8686 * @param $attr_str - source text with question attributes
8787 * @return string : type of the question, empty when not defined
8888 */
89 - function applyAttributes( $paramkeys ) {
 89+ function applyAttributes( array $paramkeys ) {
9090 $this->view->setLayout( $paramkeys[ 'layout' ], $paramkeys[ 'textwidth' ] );
9191 $this->view->setShowResults( $paramkeys[ 'showresults' ] );
9292 $this->view->setPropWidth( $paramkeys[ 'propwidth' ] );
Index: trunk/extensions/QPoll/ctrl/question/qp_textquestion.php
@@ -252,11 +252,10 @@
253253 /**
254254 * Applies previousely parsed attributes from main header into question's view
255255 * (all attributes but type)
256 - *
257 - * @param $attr_str - source text with question attributes
258 - * @return string : type of the question, empty when not defined
 256+ * @param $paramkeys array
 257+ * key is attribute name regexp match, value is the value of attribute
259258 */
260 - function applyAttributes( $paramkeys ) {
 259+ function applyAttributes( array $paramkeys ) {
261260 parent::applyAttributes( $paramkeys );
262261 if ( $this->mSubType === 'requireAllCategories' ) {
263262 # radio button prevents from filling all categories, disable it
Index: trunk/extensions/QPoll/ctrl/question/qp_stubquestion.php
@@ -33,7 +33,7 @@
3434 # load some question fields from qp_QuestionData given
3535 # (usually qp_QuestionData is an array property of qp_PollStore instance)
3636 # @param $qdata - an instance of qp_QuestionData
37 - function loadAnswer( qp_QuestionData &$qdata ) {
 37+ function loadAnswer( qp_QuestionData $qdata ) {
3838 $this->alreadyVoted = $qdata->alreadyVoted;
3939 $this->mPrevProposalCategoryId = $qdata->ProposalCategoryId;
4040 $this->mPrevProposalCategoryText = $qdata->ProposalCategoryText;
@@ -47,7 +47,7 @@
4848
4949 # populates an instance of qp_Question with data from qp_QuestionData
5050 # @param the object of type qp_Question
51 - function getQuestionAnswer( qp_PollStore &$pollStore ) {
 51+ function getQuestionAnswer( qp_PollStore $pollStore ) {
5252 if ( $pollStore->pid !== null ) {
5353 if ( $pollStore->questionExists( $this->mQuestionId ) ) {
5454 $qdata = $pollStore->Questions[ $this->mQuestionId ];
@@ -95,12 +95,13 @@
9696 }
9797
9898 /**
99 - * @return associative array of script-generated interpretation error
100 - * messages for current question proposals (and optionally categories)
101 - * false, when there are no script-generated error messages
 99+ * @return mixed
 100+ * array (associative) of script-generated interpretation error messages
 101+ * for current question proposals (and optionally categories);
 102+ * boolean false, when there are no script-generated error messages;
102103 */
103104 function getInterpErrors() {
104 - $interpResult = &$this->poll->pollStore->interpResult;
 105+ $interpResult = $this->poll->pollStore->interpResult;
105106 if ( !is_array( $interpResult->qpcErrors ) ||
106107 !isset( $interpResult->qpcErrors[$this->mQuestionId] ) ) {
107108 return false;
Index: trunk/extensions/QPoll/ctrl/question/qp_questionstats.php
@@ -25,7 +25,7 @@
2626 # load some question fields from qp_QuestionData given
2727 # (usually qp_QuestionData is a property of qp_PollStore instance)
2828 # @param $qdata - an instance of qp_QuestionData
29 - function loadAnswer( qp_QuestionData &$qdata ) {
 29+ function loadAnswer( qp_QuestionData $qdata ) {
3030 $this->alreadyVoted = $qdata->alreadyVoted;
3131 $this->mCommonQuestion = $qdata->CommonQuestion;
3232 $this->mProposalText = $qdata->ProposalText;
@@ -41,7 +41,7 @@
4242
4343 # populates an instance of qp_Question with data from qp_QuestionData
4444 # input: the object of type qp_Question
45 - function getQuestionAnswer( qp_PollStore &$pollStore ) {
 45+ function getQuestionAnswer( qp_PollStore $pollStore ) {
4646 if ( $pollStore->pid !== null ) {
4747 if ( $pollStore->questionExists( $this->mQuestionId ) ) {
4848 $qdata = $pollStore->Questions[ $this->mQuestionId ];
Index: trunk/extensions/QPoll/qp_user.php
@@ -299,7 +299,7 @@
300300 /**
301301 * Autoload classes from the map provided
302302 */
303 - static function autoLoad( $map ) {
 303+ static function autoLoad( array $map ) {
304304 global $wgAutoloadClasses;
305305 foreach ( $map as $path => &$classes ) {
306306 if ( is_array( $classes ) ) {
@@ -517,7 +517,7 @@
518518 * @return array key is attribute regexp
519519 * value is the value of attribute or null
520520 */
521 - static function getXmlLikeAttributes( $attr_str, $attr_list ) {
 521+ static function getXmlLikeAttributes( $attr_str, array $attr_list ) {
522522 $attr_vals = array();
523523 $match = array();
524524 foreach ( $attr_list as $attr_name ) {
@@ -551,8 +551,9 @@
552552 }
553553
554554 static function onLanguageGetMagic( &$magicWords, $langCode ) {
555 - foreach ( self::ParserFunctionsWords( $langCode ) as $word => $trans )
556 - $magicWords [$word ] = $trans;
 555+ foreach ( self::ParserFunctionsWords( $langCode ) as $word => $trans ) {
 556+ $magicWords[$word] = $trans;
 557+ }
557558 return true;
558559 }
559560
Index: trunk/extensions/QPoll/includes/qp_functionshook.php
@@ -50,9 +50,9 @@
5151
5252 var $error_message = 'no_such_poll';
5353
54 - function qpuserchoice( &$parser, $frame, $args ) {
 54+ function qpuserchoice( Parser &$parser, PPFrame $frame, array $args ) {
5555 qp_Setup::onLoadAllMessages();
56 - $this->frame = &$frame;
 56+ $this->frame = $frame;
5757 $this->args = &$args;
5858 if ( isset( $args[ 0 ] ) ) {
5959 # args[0] is a poll address
@@ -101,7 +101,7 @@
102102 return false;
103103 }
104104
105 - function qpuserchoiceValidResult( $qdata ) {
 105+ function qpuserchoiceValidResult( qp_QuestionData $qdata ) {
106106 $result = '';
107107 if ( array_key_exists( $this->proposal_id, $qdata->ProposalCategoryId ) ) {
108108 foreach ( $qdata->ProposalCategoryId[ $this->proposal_id ] as $id_key => $cat_id ) {
Index: trunk/extensions/QPoll/includes/qp_xlswriter.php
@@ -92,7 +92,7 @@
9393 * for cell formatting; we store these instances in self::$format array
9494 * and then address these by passing array keys (strings with format "name").
9595 */
96 - function addFormats( $formats ) {
 96+ function addFormats( array $formats ) {
9797 foreach ( $formats as $fkey => $fdef ) {
9898 self::$fdef[$fkey] = $fdef;
9999 self::$format[$fkey] = self::$wb->addformat( $fdef );
@@ -176,7 +176,7 @@
177177 /**
178178 * Write 2d-table of data into selected column of the current row.
179179 */
180 - function writeFormattedTable( $colnum, &$table, $fkey = 'null' ) {
 180+ function writeFormattedTable( $colnum, array &$table, $fkey = 'null' ) {
181181 $ws = self::$ws;
182182 foreach ( $table as $rnum => &$row ) {
183183 foreach ( $row as $cnum => &$cell ) {
Index: trunk/extensions/QPoll/includes/qp_renderer.php
@@ -52,11 +52,13 @@
5353
5454 /**
5555 * Renders nested tag array into string
56 - * @param $tag multidimensional array of xml/html tags
 56+ * @param $tag mixed
 57+ * array (multidimensional) of xml/html tags;
 58+ * string single text node;
5759 * @return string representation of xml/html
5860 *
5961 * the stucture of $tag is like this:
60 - * array( "__tag"=>"td", "class"=>"myclass", 0=>"text before li", 1=>array( "__tag"=>"li", 0=>"text inside li" ), 2=>"text after li" )
 62+ * array( '__tag'=>'td', 'class'=>'myclass', 0=>'text before li', 1=>array( '__tag'=>'li', 0=>'text inside li' ), 2=>'text after li' )
6163 *
6264 * both tagged and tagless lists are supported
6365 */
@@ -127,7 +129,7 @@
128130 /**
129131 * add one or more CSS class name to tag class attribute
130132 */
131 - static function addClass( &$tag, $className ) {
 133+ static function addClass( array &$tag, $className ) {
132134 if ( !isset( $tag['class'] ) ) {
133135 $tag['class'] = $className;
134136 return;
@@ -152,8 +154,11 @@
153155 * each element of resulting tagarray
154156 * @return array tagarray
155157 */
156 - static function tagList( $row, $destinationAttr = 0, $rowattrs = array( '__tag' => 'td' ) ) {
157 - if ( count( $row ) <= 0 ) {
 158+ static function tagList(
 159+ array $row,
 160+ $destinationAttr = 0,
 161+ array $rowattrs = array( '__tag' => 'td' ) ) {
 162+ if ( count( $row ) < 1 ) {
158163 return '';
159164 }
160165 $result = array();
@@ -174,7 +179,11 @@
175180 * destination cell xml attributes ("name"=>0, "count"=>colspan" )
176181 * @return array of destination cells
177182 */
178 - static function newRow( $row, $rowattrs = "", $celltag = "td", $attribute_maps = null ) {
 183+ static function newRow(
 184+ array $row,
 185+ array $rowattrs = array(),
 186+ $celltag = "td",
 187+ array $attribute_maps = array() ) {
179188 $result = "";
180189 if ( count( $row ) > 0 ) {
181190 foreach ( $row as &$cell ) {
@@ -183,21 +192,18 @@
184193 }
185194 $cell['__tag'] = $celltag;
186195 $cell['__end'] = "\n";
187 - if ( is_array( $attribute_maps ) ) {
188 - # converts ("count"=>3) to ("colspan"=>3) in table headers - don't use frequently
189 - foreach ( $attribute_maps as $key => $val ) {
190 - if ( array_key_exists( $key, $cell ) ) {
191 - $cell[ $val ] = $cell[ $key ];
192 - unset( $cell[ $key ] );
193 - }
 196+ # converts ("count"=>3) to ("colspan"=>3) in table headers
 197+ # please don't use frequently, because it's inefficient
 198+ foreach ( $attribute_maps as $key => $val ) {
 199+ if ( array_key_exists( $key, $cell ) ) {
 200+ $cell[ $val ] = $cell[ $key ];
 201+ unset( $cell[ $key ] );
194202 }
195203 }
196204 }
197205 $result = array( '__tag' => 'tr', 0 => $row, '__end' => "\n" );
198 - if ( is_array( $rowattrs ) ) {
 206+ if ( count( $rowattrs ) > 0 ) {
199207 $result = array_merge( $rowattrs, $result );
200 - } elseif ( $rowattrs !== "" ) {
201 - $result[0][] = __METHOD__ . ':invalid rowattrs supplied';
202208 }
203209 }
204210 return $result;
@@ -207,7 +213,12 @@
208214 * Add row to the table
209215 * todo: document
210216 */
211 - static function addRow( &$table, $row, $rowattrs = "", $celltag = "td", $attribute_maps = null ) {
 217+ static function addRow(
 218+ array &$table,
 219+ array $row,
 220+ array $rowattrs = array(),
 221+ $celltag = "td",
 222+ array $attribute_maps = array() ) {
212223 $table[] = self::newRow( $row, $rowattrs, $celltag, $attribute_maps );
213224 }
214225
@@ -215,7 +226,12 @@
216227 * Add column to the table
217228 * todo: document
218229 */
219 - static function addColumn( &$table, $column, $rowattrs = "", $celltag = "td", $attribute_maps = null ) {
 230+ static function addColumn(
 231+ array &$table,
 232+ array $column,
 233+ array $rowattrs = array(),
 234+ $celltag = "td",
 235+ array $attribute_maps = array() ) {
220236 if ( count( $column ) > 0 ) {
221237 $row = 0;
222238 foreach ( $column as &$cell ) {
@@ -224,19 +240,15 @@
225241 }
226242 $cell[ '__tag' ] = $celltag;
227243 $cell[ '__end' ] = "\n";
228 - if ( is_array( $attribute_maps ) ) {
229 - # converts ("count"=>3) to ("rowspan"=>3) in table headers - don't use frequently
230 - foreach ( $attribute_maps as $key => $val ) {
231 - if ( array_key_exists( $key, $cell ) ) {
232 - $cell[ $val ] = $cell[ $key ];
233 - unset( $cell[ $key ] );
234 - }
 244+ # converts ("count"=>3) to ("rowspan"=>3) in table headers - don't use frequently
 245+ foreach ( $attribute_maps as $key => $val ) {
 246+ if ( array_key_exists( $key, $cell ) ) {
 247+ $cell[ $val ] = $cell[ $key ];
 248+ unset( $cell[ $key ] );
235249 }
236250 }
237 - if ( is_array( $rowattrs ) ) {
 251+ if ( count( $rowattrs ) > 0 ) {
238252 $cell = array_merge( $rowattrs, $cell );
239 - } elseif ( $rowattrs !== "" ) {
240 - $cell[ 0 ] = __METHOD__ . ':invalid rowattrs supplied';
241253 }
242254 if ( !array_key_exists( $row, $table ) ) {
243255 $table[ $row ] = array( '__tag' => 'tr', '__end' => "\n" );
@@ -252,7 +264,11 @@
253265 }
254266 }
255267
256 - static function displayRow( $row, $rowattrs = "", $celltag = "td", $attribute_maps = null ) {
 268+ static function displayRow(
 269+ array $row,
 270+ array $rowattrs = array(),
 271+ $celltag = "td",
 272+ array $attribute_maps = array() ) {
257273 # temporary var $tagsrow used to avoid warning in E_STRICT mode
258274 $tagsrow = self::newRow( $row, $rowattrs, $celltag, $attribute_maps );
259275 return self::renderTagArray( $tagsrow );
@@ -262,8 +278,8 @@
263279 * use newRow() or addColumn() to add resulting row/column to the table
264280 * if you want to use the resulting row with renderTagArray(), don't forget to apply attrs=array('__tag'=>'td')
265281 */
266 - static function applyAttrsToRow( &$row, $attrs ) {
267 - if ( is_array( $attrs ) && count( $attrs > 0 ) ) {
 282+ static function applyAttrsToRow( array &$row, array $attrs ) {
 283+ if ( count( $attrs > 0 ) ) {
268284 foreach ( $row as &$cell ) {
269285 if ( !is_array( $cell ) ) {
270286 $cell = array_merge( $attrs, array( $cell ) );
Index: trunk/extensions/QPoll/interpretation/qp_interpret.php
@@ -68,7 +68,7 @@
6969 * or false, when the poll questions were not randomized
7070 * @return instance of qp_InterpResult class (interpretation result)
7171 */
72 - static function getResult( $interpArticle, $injectVars ) {
 72+ static function getResult( Article $interpArticle, array $injectVars ) {
7373 global $wgParser, $wgContLang;
7474 $matches = array();
7575 # extract <qpinterpret> tags from the article content
Index: trunk/extensions/QPoll/interpretation/qp_eval.php
@@ -224,9 +224,10 @@
225225
226226 /**
227227 * Calls php interpreter to lint interpretation script code
228 - * @param $code string with php code
229 - * @return bool true, when code has no syntax errors;
230 - * string error message from php lint
 228+ * @param $code string with php code
 229+ * @return mixed
 230+ * boolean true, when code has no syntax errors;
 231+ * string error message from php lint;
231232 */
232233 static function lint( $code ) {
233234 $pipes = array();
@@ -312,9 +313,13 @@
313314 /**
314315 * Checks the submitted eval code for errors
315316 * In case of success returns transformed code, which is safer for eval
316 - * @param $sourceCode submitted code which has to be eval'ed (no php tags)
317 - * @param $destinationCode transformed code (in case of success) (no php tags)
318 - * @return boolean true in case of success, string with error message on failure
 317+ * @param $sourceCode string
 318+ * submitted code which has to be eval'ed (no php tags)
 319+ * @param $destinationCode string
 320+ * transformed code (in case of success) (no php tags)
 321+ * @return mixed
 322+ * boolean true in case of success;
 323+ * string error message on failure;
319324 */
320325 static function checkAndTransformCode( $sourceCode, &$destinationCode ) {
321326
@@ -382,18 +387,22 @@
383388
384389 /**
385390 * Interpretates the answer with selected script
386 - * @param $interpretScript string source code of interpretation script
387 - * @param $injectVars array of PHP data to inject into interpretation script;
388 - * key of element will become variable name
389 - * in the interpretation script;
390 - * value of element will become variable value
391 - * in the interpretation script;
392 - * @param $interpResult instance of qp_InterpResult class
 391+ * @param $interpretScript
 392+ * string source code of interpretation script
 393+ * @param $injectVars
 394+ * array of PHP data to inject into interpretation script;
 395+ * key of element will become variable name in the interpretation script;
 396+ * value of element will become variable value in the interpretation script;
 397+ * @param $interpResult qp_InterpResult
393398 * @modifies $interpResult
394 - * @return array script result to check, or
395 - * qp_InterpResult $interpResult (in case of error)
 399+ * @return mixed
 400+ * array script result to check
 401+ * qp_InterpResult $interpResult (in case of error)
396402 */
397 - static function interpretAnswer( $interpretScript, $injectVars, qp_InterpResult $interpResult ) {
 403+ static function interpretAnswer(
 404+ $interpretScript,
 405+ array $injectVars,
 406+ qp_InterpResult $interpResult ) {
398407 # template page evaluation
399408 if ( ( $check = self::selfCheck() ) !== true ) {
400409 # self-check error
Index: trunk/extensions/QPoll/view/proposal/qp_tabularquestionproposalview.php
@@ -185,7 +185,7 @@
186186 * @return boolean true when at least one category was found in the list
187187 * false otherwise
188188 */
189 - function applyInterpErrors( $prop_desc ) {
 189+ function applyInterpErrors( array $prop_desc ) {
190190 $foundCats = false;
191191 # scan the category views row to highlight erroneous categories
192192 foreach ( $this->row as $cat_id => &$cat_tag ) {
Index: trunk/extensions/QPoll/view/proposal/qp_textquestionproposalview.php
@@ -126,7 +126,7 @@
127127 * @return boolean true when at least one category was found in the list
128128 * false otherwise
129129 */
130 - function applyInterpErrors( $prop_desc ) {
 130+ function applyInterpErrors( array $prop_desc ) {
131131 $foundCats = false;
132132 $cat_id = -1;
133133 foreach ( $this->viewtokens as &$token ) {
Index: trunk/extensions/QPoll/view/qp_interpresultview.php
@@ -53,7 +53,7 @@
5454 /**
5555 * Add interpretation results to tagarray of poll view
5656 */
57 - function showInterpResults( &$tagarray, qp_InterpResult $ctrl, $showDescriptions = false ) {
 57+ function showInterpResults( array &$tagarray, qp_InterpResult $ctrl, $showDescriptions = false ) {
5858 if ( $ctrl->hasVisibleProperties() ) {
5959 return;
6060 }
@@ -92,7 +92,7 @@
9393 foreach ( $strucTable as &$line ) {
9494 if ( isset( $line['keys'] ) ) {
9595 # current node is associative array
96 - qp_Renderer::addRow( $rows, $line['keys'], '', 'th' );
 96+ qp_Renderer::addRow( $rows, $line['keys'], array(), 'th' );
9797 qp_Renderer::addRow( $rows, $line['vals'] );
9898 } else {
9999 # current node is scalar value
Index: trunk/extensions/QPoll/view/results/qp_questiondataresults.php
@@ -22,7 +22,7 @@
2323 $this->ctrl = $ctrl;
2424 }
2525
26 - protected function categoryentities( $cat ) {
 26+ protected function categoryentities( array $cat ) {
2727 $cat['name'] = qp_Setup::entities( $cat['name'] );
2828 return $cat;
2929 }
@@ -33,8 +33,18 @@
3434 function displayUserQuestionVote() {
3535 $ctrl = $this->ctrl;
3636 $output = "<div class=\"qpoll\">\n" . "<table class=\"qdata\">\n";
37 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ), array( 'class' => 'spans' ), 'th', array( 'count' => 'colspan', 'name' => 0 ) );
38 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->Categories ), '', 'th', array( 'name' => 0 ) );
 37+ $output .= qp_Renderer::displayRow(
 38+ array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ),
 39+ array( 'class' => 'spans' ),
 40+ 'th',
 41+ array( 'count' => 'colspan', 'name' => 0 )
 42+ );
 43+ $output .= qp_Renderer::displayRow(
 44+ array_map( array( $this, 'categoryentities' ), $ctrl->Categories ),
 45+ array(),
 46+ 'th',
 47+ array( 'name' => 0 )
 48+ );
3949 # multiple choice polls doesn't use real spans, instead, every column is like "span"
4050 $spansUsed = count( $ctrl->CategorySpans ) > 0 || $ctrl->type == "multipleChoice";
4151 foreach ( $ctrl->ProposalText as $propkey => &$proposal_text ) {
@@ -80,8 +90,18 @@
8191 $current_title = $page->getTitle();
8292 $output = "<br />\n<b>" . $ctrl->question_id . ".</b> " . qp_Setup::entities( $ctrl->CommonQuestion ) . "<br />\n";
8393 $output .= "<div class=\"qpoll\">\n" . "<table class=\"qdata\">\n";
84 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ), array( 'class' => 'spans' ), 'th', array( 'count' => 'colspan', 'name' => 0 ) );
85 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->Categories ), '', 'th', array( 'name' => 0 ) );
 94+ $output .= qp_Renderer::displayRow(
 95+ array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ),
 96+ array( 'class' => 'spans' ),
 97+ 'th',
 98+ array( 'count' => 'colspan', 'name' => 0 )
 99+ );
 100+ $output .= qp_Renderer::displayRow(
 101+ array_map( array( $this, 'categoryentities' ), $ctrl->Categories ),
 102+ array(),
 103+ 'th',
 104+ array( 'name' => 0 )
 105+ );
86106 # multiple choice polls doesn't use real spans, instead, every column is like "span"
87107 $spansUsed = count( $ctrl->CategorySpans ) > 0 || $ctrl->type == "multipleChoice";
88108 foreach ( $ctrl->ProposalText as $propkey => &$proposal_text ) {
Index: trunk/extensions/QPoll/view/results/qp_textquestiondataresults.php
@@ -100,7 +100,10 @@
101101 throw new MWException( 'DB token has invalid type (' . gettype( $token ) . ') in ' . __METHOD__ );
102102 }
103103 }
104 - $output .= qp_Renderer::displayRow( array( $row ), array( 'class' => 'qdatatext' ) );
 104+ $output .= qp_Renderer::displayRow(
 105+ array( $row ),
 106+ array( 'class' => 'qdatatext' )
 107+ );
105108 }
106109 $output .= "</table>\n" . "</div>\n";
107110 return $output;
Index: trunk/extensions/QPoll/view/qp_abstractview.php
@@ -60,9 +60,9 @@
6161 * @param $parser instance of parser for current tag hook
6262 * @param $ppframe instance of ppframe for current tag hook
6363 */
64 - function __construct( &$parser, &$frame ) {
65 - $this->parser = &$parser;
66 - $this->ppframe = &$frame;
 64+ function __construct( Parser $parser, PPFrame $frame ) {
 65+ $this->parser = $parser;
 66+ $this->ppframe = $frame;
6767 $this->linker = new Linker();
6868 }
6969
@@ -84,7 +84,12 @@
8585 $this->ctrl = $ctrl;
8686 }
8787
88 - function link( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) {
 88+ function link(
 89+ $target,
 90+ $text = null,
 91+ array $customAttribs = array(),
 92+ array $query = array(),
 93+ array $options = array() ) {
8994 return $this->linker->link( $target, $text, $customAttribs, $query, $options );
9095 }
9196
Index: trunk/extensions/QPoll/view/xls/qp_xlstabularquestion.php
@@ -31,7 +31,7 @@
3232 $this->writeRowLn( 0, $row );
3333 }
3434
35 - function writeQuestionVoice( $pvoices ) {
 35+ function writeQuestionVoice( array $pvoices ) {
3636 $qdata = $this->qdata;
3737 # create square table of proposal / category answers for each uid in uvoices array
3838 $voicesTable = array();
Index: trunk/extensions/QPoll/view/xls/qp_xlspoll.php
@@ -68,7 +68,7 @@
6969 function voicesToXls( qp_PollStore $pollStore ) {
7070 $pollStore->loadQuestions();
7171 $first_question = true;
72 - foreach ( $pollStore->Questions as $qkey => &$qdata ) {
 72+ foreach ( $pollStore->Questions as $qkey => $qdata ) {
7373 $xlsq = ( $qdata->type === 'textQuestion' ) ? $this->text_writer : $this->tabular_writer;
7474 $xlsq->setQuestionData( $qdata );
7575 if ( $first_question ) {
@@ -115,7 +115,7 @@
116116 $pollStore->loadTotals();
117117 $pollStore->calculateStatistics();
118118 $first_question = true;
119 - foreach ( $pollStore->Questions as $qkey => &$qdata ) {
 119+ foreach ( $pollStore->Questions as $qkey => $qdata ) {
120120 $xlsq = ( $qdata->type === 'textQuestion' ) ? $this->text_writer : $this->tabular_writer;
121121 $xlsq->setQuestionData( $qdata );
122122 if ( $first_question ) {
Index: trunk/extensions/QPoll/view/xls/qp_xlstextquestion.php
@@ -11,7 +11,7 @@
1212 ) );
1313 }
1414
15 - function writeQuestionVoice( $pvoices ) {
 15+ function writeQuestionVoice( array $pvoices ) {
1616 $qdata = $this->qdata;
1717 foreach ( $qdata->ProposalText as $propkey => &$serialized_tokens ) {
1818 # Create 2D-table of proposal / category answers for each uid in uvoices array
Index: trunk/extensions/QPoll/view/question/qp_tabularquestionview.php
@@ -68,7 +68,7 @@
6969 * @param $frame
7070 * @param $showResults poll's showResults (may be overriden in the question)
7171 */
72 - function __construct( &$parser, &$frame, $showResults ) {
 72+ function __construct( Parser $parser, PPFrame $frame, $showResults ) {
7373 parent::__construct( $parser, $frame );
7474 $this->pollShowResults = $showResults;
7575 }
@@ -143,7 +143,7 @@
144144 * Builds tagarray of categories
145145 * @param $categories "raw" categories
146146 */
147 - function buildCategoriesRow( $categories ) {
 147+ function buildCategoriesRow( array $categories ) {
148148 $row = array();
149149 if ( $this->proposalsFirst ) {
150150 // add empty <th> at the begin of row to "compensate" proposal text
@@ -163,7 +163,7 @@
164164 * Builds tagarray of category spans
165165 * @param $categorySpans "raw" spans
166166 */
167 - function buildSpansRow( $categorySpans ) {
 167+ function buildSpansRow( array $categorySpans ) {
168168 $row = array();
169169 if ( $this->proposalsFirst ) {
170170 // add empty <th> at the begin of row to "compensate" proposal text
@@ -238,7 +238,7 @@
239239 }
240240 if ( isset( $this->pviews[$prop_id] ) ) {
241241 # the whole proposal line has errors
242 - $propview = &$this->pviews[$prop_id];
 242+ $propview = $this->pviews[$prop_id];
243243 if ( !is_array( $prop_desc ) ) {
244244 if ( !is_string( $prop_desc ) ) {
245245 $prop_desc = wfMsg( 'qp_interpetation_wrong_answer' );
@@ -267,11 +267,11 @@
268268 $questionTable = array();
269269 # add header views to $questionTable
270270 foreach ( $this->hviews as $header ) {
271 - $rowattrs = '';
272 - $attribute_maps = null;
 271+ $rowattrs = array();
 272+ $attribute_maps = array();
273273 if ( is_object( $header ) ) {
274274 $row = &$header->row;
275 - $rowattrs = array( 'class' => $header->className );
 275+ $rowattrs['class'] = $header->className;
276276 $attribute_maps = &$header->attribute_maps;
277277 } else {
278278 $row = &$header;
Index: trunk/extensions/QPoll/view/question/qp_stubquestionview.php
@@ -61,7 +61,7 @@
6262 * @param $parser
6363 * @param $frame
6464 */
65 - function __construct( &$parser, &$frame ) {
 65+ function __construct( Parser $parser, PPFrame $frame ) {
6666 parent::__construct( $parser, $frame );
6767 }
6868
@@ -104,7 +104,7 @@
105105 * @param $className CSS class name of row
106106 * @param $attribute_maps translation of source attributes into html attributes (see qp_Renderer class)
107107 */
108 - function addHeaderRow( $row, $className, $attribute_maps = null ) {
 108+ function addHeaderRow( $row, $className, array $attribute_maps = array() ) {
109109 $this->hviews[] = (object) array(
110110 'row' => $row,
111111 'className' => $className,
@@ -126,11 +126,11 @@
127127 $questionTable = array();
128128 # add header views to $questionTable
129129 foreach ( $this->hviews as $header ) {
130 - $rowattrs = '';
131 - $attribute_maps = null;
 130+ $rowattrs = array();
 131+ $attribute_maps = array();
132132 if ( is_object( $header ) ) {
133133 $row = &$header->row;
134 - $rowattrs = array( 'class' => $header->className );
 134+ $rowattrs['class'] = $header->className;
135135 $attribute_maps = &$header->attribute_maps;
136136 } else {
137137 $row = &$header;
Index: trunk/extensions/QPoll/view/question/qp_textquestionview.php
@@ -79,7 +79,7 @@
8080 /**
8181 * Add proposal error tagarray
8282 */
83 - function addError( $elem ) {
 83+ function addError( stdClass $elem ) {
8484 $this->cell[] = array(
8585 '__tag' => 'span',
8686 'class' => 'proposalerror',
@@ -90,7 +90,7 @@
9191 /**
9292 * Add category as input type text / checkbox / radio / textarea tagarray
9393 */
94 - function addInput( $elem, $className ) {
 94+ function addInput( stdClass $elem, $className ) {
9595 $tagName = ( $elem->type === 'text' && $elem->attributes['height'] !== 0 ) ? 'textarea' : 'input';
9696 $lines_count = 1;
9797 # get category value
@@ -153,7 +153,7 @@
154154 /**
155155 * Add category as select / option list tagarray
156156 */
157 - function addSelect( $elem, $className ) {
 157+ function addSelect( stdClass $elem, $className ) {
158158 if ( $elem->options[0] !== '' ) {
159159 # default element in select/option set always must be an empty option
160160 array_unshift( $elem->options, '' );
@@ -209,7 +209,7 @@
210210 /**
211211 * Add tagarray representation of proposal part
212212 */
213 - function addProposalPart( $elem ) {
 213+ function addProposalPart( /* string */ $elem ) {
214214 $this->cell[] = array(
215215 '__tag' => 'span',
216216 'class' => 'prop_part',
@@ -268,7 +268,7 @@
269269 * @param $frame
270270 * @param $showResults poll's showResults (may be overriden in the question)
271271 */
272 - function __construct( &$parser, &$frame, $showResults ) {
 272+ function __construct( Parser $parser, PPFrame $frame, $showResults ) {
273273 parent::__construct( $parser, $frame );
274274 $this->vr = new qp_TextQuestionViewRow( $this );
275275 /* todo: implement showResults */
@@ -319,7 +319,7 @@
320320 }
321321 if ( isset( $this->pviews[$prop_id] ) ) {
322322 # the whole proposal line has errors
323 - $propview = &$this->pviews[$prop_id];
 323+ $propview = $this->pviews[$prop_id];
324324 if ( !is_array( $prop_desc ) ) {
325325 if ( !is_string( $prop_desc ) ) {
326326 $prop_desc = wfMsg( 'qp_interpetation_wrong_answer' );
@@ -350,7 +350,7 @@
351351 * @param $viewtokens array of viewtokens
352352 * @return tagarray
353353 */
354 - function renderParsedProposal( $pkey, &$viewtokens ) {
 354+ function renderParsedProposal( $pkey, array &$viewtokens ) {
355355 $vr = $this->vr;
356356 # proposal prefix for category tag id generation
357357 $vr->reset( "tx{$this->ctrl->poll->mOrderId}q{$this->ctrl->mQuestionId}p{$pkey}" );
@@ -411,18 +411,18 @@
412412 $questionTable = array();
413413 # add header views to $questionTable
414414 foreach ( $this->hviews as $header ) {
415 - $rowattrs = '';
416 - $attribute_maps = null;
 415+ $rowattrs = array();
 416+ $attribute_maps = array();
417417 if ( is_object( $header ) ) {
418418 $row = &$header->row;
419 - $rowattrs = array( 'class' => $header->className );
 419+ $rowattrs['class'] = $header->className;
420420 $attribute_maps = &$header->attribute_maps;
421421 } else {
422422 $row = &$header;
423423 }
424424 qp_Renderer::addRow( $questionTable, $row, $rowattrs, 'th', $attribute_maps );
425425 }
426 - foreach ( $this->pviews as $pkey => &$propview ) {
 426+ foreach ( $this->pviews as $pkey => $propview ) {
427427 $prop = $this->renderParsedProposal( $pkey, $propview->viewtokens );
428428 $rowattrs = array( 'class' => $propview->rowClass );
429429 if ( $this->transposed ) {

Status & tagging log