Add type hint for ParserOutput
authorFomafix <fomafix@googlemail.com>
Fri, 27 Jul 2018 20:20:39 +0000 (22:20 +0200)
committerFomafix <fomafix@googlemail.com>
Mon, 30 Jul 2018 07:23:59 +0000 (09:23 +0200)
EditPage::getPreviewLimitReport is called by EditPage::showEditForm
with $output = null. Specify this in the @param tag and allow this by a
default value.

Change-Id: Iec8905aab736a1f254a57853c7cab935d008653e

includes/EditPage.php
includes/OutputPage.php
includes/page/Article.php
includes/parser/ParserCache.php

index 16f1c5a..2022636 100644 (file)
@@ -3588,10 +3588,10 @@ ERROR;
         * Get the Limit report for page previews
         *
         * @since 1.22
-        * @param ParserOutput $output ParserOutput object from the parse
+        * @param ParserOutput|null $output ParserOutput object from the parse
         * @return string HTML
         */
-       public static function getPreviewLimitReport( $output ) {
+       public static function getPreviewLimitReport( ParserOutput $output = null ) {
                global $wgLang;
 
                if ( !$output || !$output->getLimitReportData() ) {
index 1dc996a..ec13bb9 100644 (file)
@@ -1771,7 +1771,7 @@ class OutputPage extends ContextSource {
         * @since 1.24
         * @param ParserOutput $parserOutput
         */
-       public function addParserOutputMetadata( $parserOutput ) {
+       public function addParserOutputMetadata( ParserOutput $parserOutput ) {
                $this->mLanguageLinks =
                        array_merge( $this->mLanguageLinks, $parserOutput->getLanguageLinks() );
                $this->addCategoryLinks( $parserOutput->getCategories() );
@@ -1848,7 +1848,7 @@ class OutputPage extends ContextSource {
         * @param ParserOutput $parserOutput
         * @param array $poOptions Options to ParserOutput::getText()
         */
-       public function addParserOutputContent( $parserOutput, $poOptions = [] ) {
+       public function addParserOutputContent( ParserOutput $parserOutput, $poOptions = [] ) {
                $this->addParserOutputText( $parserOutput, $poOptions );
 
                $this->addModules( $parserOutput->getModules() );
@@ -1865,7 +1865,7 @@ class OutputPage extends ContextSource {
         * @param ParserOutput $parserOutput
         * @param array $poOptions Options to ParserOutput::getText()
         */
-       public function addParserOutputText( $parserOutput, $poOptions = [] ) {
+       public function addParserOutputText( ParserOutput $parserOutput, $poOptions = [] ) {
                $text = $parserOutput->getText( $poOptions );
                // Avoid PHP 7.1 warning of passing $this by reference
                $outputPage = $this;
@@ -1879,7 +1879,7 @@ class OutputPage extends ContextSource {
         * @param ParserOutput $parserOutput
         * @param array $poOptions Options to ParserOutput::getText()
         */
-       function addParserOutput( $parserOutput, $poOptions = [] ) {
+       function addParserOutput( ParserOutput $parserOutput, $poOptions = [] ) {
                $this->addParserOutputMetadata( $parserOutput );
                $this->addParserOutputText( $parserOutput, $poOptions );
        }
index 49912c7..3a7b18e 100644 (file)
@@ -750,7 +750,7 @@ class Article implements Page {
         * @return array The policy that should be set
         * @todo actions other than 'view'
         */
-       public function getRobotPolicy( $action, $pOutput = null ) {
+       public function getRobotPolicy( $action, ParserOutput $pOutput = null ) {
                global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
 
                $ns = $this->getTitle()->getNamespace();
index e6326e6..5e6081d 100644 (file)
@@ -294,7 +294,13 @@ class ParserCache {
         * @param string|null $cacheTime TS_MW timestamp when the cache was generated
         * @param int|null $revId Revision ID that was parsed
         */
-       public function save( $parserOutput, $page, $popts, $cacheTime = null, $revId = null ) {
+       public function save(
+               ParserOutput $parserOutput,
+               $page,
+               $popts,
+               $cacheTime = null,
+               $revId = null
+       ) {
                $expire = $parserOutput->getCacheExpiry();
                if ( $expire > 0 && !$this->mMemc instanceof EmptyBagOStuff ) {
                        $cacheTime = $cacheTime ?: wfTimestampNow();