From 1b116394cf160d1dedecf4fcbff28e0b8cfbff0a Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 26 Jun 2018 16:35:09 +0100 Subject: [PATCH] Correct documentation of $title Title object and add type hints Change-Id: I8108161e2330d54e9e3f9969ead9352cc5810fb0 --- includes/ApiVisualEditor.php | 12 ++++++------ includes/ApiVisualEditorEdit.php | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/includes/ApiVisualEditor.php b/includes/ApiVisualEditor.php index fde6298ec6..f4124e9215 100644 --- a/includes/ApiVisualEditor.php +++ b/includes/ApiVisualEditor.php @@ -132,11 +132,11 @@ class ApiVisualEditor extends ApiBase { /** * Run wikitext through the parser's Pre-Save-Transform * - * @param string $title The title of the page to use as the parsing context + * @param Title $title The title of the page to use as the parsing context * @param string $wikitext The wikitext to transform * @return string The transformed wikitext */ - protected function pstWikitext( $title, $wikitext ) { + protected function pstWikitext( Title $title, $wikitext ) { return ContentHandler::makeContent( $wikitext, $title, CONTENT_MODEL_WIKITEXT ) ->preSaveTransform( $title, @@ -170,11 +170,11 @@ class ApiVisualEditor extends ApiBase { * * @param string $preload The title of the page to use as the preload content * @param string[] $params The preloadTransform parameters to pass in, if any - * @param string $contextTitle The contextual page title against which to parse the preload + * @param Title $contextTitle The contextual page title against which to parse the preload * @param bool $parse Whether to parse the preload content * @return string The parsed content */ - protected function getPreloadContent( $preload, $params, $contextTitle, $parse = false ) { + protected function getPreloadContent( $preload, $params, Title $contextTitle, $parse = false ) { $content = ''; $preloadTitle = Title::newFromText( $preload ); // Check for existence to avoid getting MediaWiki:Noarticletext @@ -725,11 +725,11 @@ class ApiVisualEditor extends ApiBase { /** * Gets the relevant HTML for the latest log entry on a given title, including a full log link. * - * @param $title Title + * @param Title $title Title * @param $types array|string * @return string */ - private function getLastLogEntry( $title, $types = '' ) { + private function getLastLogEntry( Title $title, $types = '' ) { $lp = new LogPager( new LogEventsList( $this->getContext() ), $types, diff --git a/includes/ApiVisualEditorEdit.php b/includes/ApiVisualEditorEdit.php index d11d3bfe8e..b4a26092e1 100644 --- a/includes/ApiVisualEditorEdit.php +++ b/includes/ApiVisualEditorEdit.php @@ -23,12 +23,12 @@ class ApiVisualEditorEdit extends ApiVisualEditor { /** * Attempt to save a given page's wikitext to MediaWiki's storage layer via its API * - * @param string $title The title of the page to write + * @param Title $title The title of the page to write * @param string $wikitext The wikitext to write * @param array $params The edit parameters * @return Status The result of the save attempt */ - protected function saveWikitext( $title, $wikitext, $params ) { + protected function saveWikitext( Title $title, $wikitext, $params ) { $apiParams = [ 'action' => 'edit', 'title' => $title->getPrefixedDBkey(), @@ -163,12 +163,12 @@ class ApiVisualEditorEdit extends ApiVisualEditor { /** * Create and load the parsed wikitext of an edit, or from the serialisation cache if available. * - * @param string $title The title of the page + * @param Title $title The title of the page * @param array $params The edit parameters * @param array $parserParams The parser parameters * @return string The wikitext of the edit */ - protected function getWikitext( $title, $params, $parserParams ) { + protected function getWikitext( Title $title, $params, $parserParams ) { if ( $params['cachekey'] !== null ) { $wikitext = $this->trySerializationCache( $params['cachekey'] ); if ( !is_string( $wikitext ) ) { @@ -183,12 +183,12 @@ class ApiVisualEditorEdit extends ApiVisualEditor { /** * Create and load the parsed wikitext of an edit, ignoring the serialisation cache. * - * @param string $title The title of the page + * @param Title $title The title of the page * @param array $params The edit parameters * @param array $parserParams The parser parameters * @return string The wikitext of the edit */ - protected function getWikitextNoCache( $title, $params, $parserParams ) { + protected function getWikitextNoCache( Title $title, $params, $parserParams ) { $this->requireOnlyOneParameter( $params, 'html' ); $wikitext = $this->postHTML( $title, self::tryDeflate( $params['html'] ), $parserParams, $params['etag'] @@ -202,11 +202,11 @@ class ApiVisualEditorEdit extends ApiVisualEditor { /** * Load the parsed wikitext of an edit into the serialisation cache. * - * @param string $title The title of the page + * @param Title $title The title of the page * @param string $wikitext The wikitext of the edit * @return string The key of the wikitext in the serialisation cache */ - protected function storeInSerializationCache( $title, $wikitext ) { + protected function storeInSerializationCache( Title $title, $wikitext ) { global $wgMemc; if ( $wikitext === false ) { @@ -251,13 +251,13 @@ class ApiVisualEditorEdit extends ApiVisualEditor { * Transform HTML to wikitext via Parsoid through RESTbase. * * @param string $path The RESTbase path of the transform endpoint - * @param string $title The title of the page + * @param Title $title The title of the page * @param array $data An array of the HTML and the 'scrub_wikitext' option * @param array $parserParams Parsoid parser paramters to pass in * @param string $etag The ETag to set in the HTTP request header * @return string Body of the RESTbase server's response */ - protected function postData( $path, $title, $data, $parserParams, $etag ) { + protected function postData( $path, Title $title, $data, $parserParams, $etag ) { $path .= urlencode( $title->getPrefixedDBkey() ); if ( isset( $parserParams['oldid'] ) && $parserParams['oldid'] ) { $path .= '/' . $parserParams['oldid']; @@ -271,13 +271,13 @@ class ApiVisualEditorEdit extends ApiVisualEditor { /** * Transform HTML to wikitext via Parsoid through RESTbase. Wrapper for ::postData(). * - * @param string $title The title of the page + * @param Title $title The title of the page * @param string $html The HTML of the page to be transformed * @param array $parserParams Parsoid parser paramters to pass in * @param string $etag The ETag to set in the HTTP request header * @return string Body of the RESTbase server's response */ - protected function postHTML( $title, $html, $parserParams, $etag ) { + protected function postHTML( Title $title, $html, $parserParams, $etag ) { return $this->postData( 'transform/html/to/wikitext/', $title, [ 'html' => $html, 'scrub_wikitext' => 1 ], $parserParams, $etag @@ -287,13 +287,13 @@ class ApiVisualEditorEdit extends ApiVisualEditor { /** * Calculate the different between the wikitext of an edit and an existing revision. * - * @param string $title The title of the page + * @param Title $title The title of the page * @param int $fromId The existing revision of the page to compare with * @param string $wikitext The wikitext to compare against * @param int|null $section Whether the wikitext refers to a given section or the whole page * @return array The comparison, or `[ 'result' => 'nochanges' ]` if there are none */ - protected function diffWikitext( $title, $fromId, $wikitext, $section = null ) { + protected function diffWikitext( Title $title, $fromId, $wikitext, $section = null ) { $apiParams = [ 'action' => 'compare', 'prop' => 'diff',