Fix/update inline documentation in WikiPage class
* Add missing "new" to methods that actually support it. * Use more precise type hints in PHPDoc comments. * Lowercase "string" and "array", they aren't objects. * Drop a useless comment that only repeats the method name. * Add some line breaks. Change-Id: I2f50179eedffcb1809c46fa7ee1c062144a94ffe
This commit is contained in:
parent
587a98aa02
commit
c72b98e8d6
1 changed files with 27 additions and 19 deletions
|
|
@ -104,9 +104,10 @@ class WikiPage implements Page, IDBAccessObject {
|
||||||
/**
|
/**
|
||||||
* Create a WikiPage object of the appropriate class for the given title.
|
* Create a WikiPage object of the appropriate class for the given title.
|
||||||
*
|
*
|
||||||
* @param $title Title
|
* @param Title $title
|
||||||
|
*
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
* @return WikiPage object of the appropriate type
|
* @return WikiPage Object of the appropriate type
|
||||||
*/
|
*/
|
||||||
public static function factory( Title $title ) {
|
public static function factory( Title $title ) {
|
||||||
$ns = $title->getNamespace();
|
$ns = $title->getNamespace();
|
||||||
|
|
@ -1468,12 +1469,13 @@ class WikiPage implements Page, IDBAccessObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $section null|bool|int or a section number (0, 1, 2, T1, T2...)
|
* @param mixed $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
|
||||||
* @param string $text new text of the section
|
* @param string $text New text of the section.
|
||||||
* @param string $sectionTitle new section's subject, only if $section is 'new'
|
* @param string $sectionTitle New section's subject, only if $section is "new".
|
||||||
* @param string $edittime revision timestamp or null to use the current revision
|
* @param string $edittime Revision timestamp or null to use the current revision.
|
||||||
|
*
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
* @return String new complete article text, or null if error
|
* @return string New complete article text, or null if error.
|
||||||
*
|
*
|
||||||
* @deprecated since 1.21, use replaceSectionContent() instead
|
* @deprecated since 1.21, use replaceSectionContent() instead
|
||||||
*/
|
*/
|
||||||
|
|
@ -1486,13 +1488,15 @@ class WikiPage implements Page, IDBAccessObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$this->supportsSections() ) {
|
if ( !$this->supportsSections() ) {
|
||||||
throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() );
|
throw new MWException( "sections not supported for content model " .
|
||||||
|
$this->getContentHandler()->getModelID() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// could even make section title, but that's not required.
|
// could even make section title, but that's not required.
|
||||||
$sectionContent = ContentHandler::makeContent( $text, $this->getTitle() );
|
$sectionContent = ContentHandler::makeContent( $text, $this->getTitle() );
|
||||||
|
|
||||||
$newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle, $edittime );
|
$newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle,
|
||||||
|
$edittime );
|
||||||
|
|
||||||
return ContentHandler::getContentText( $newContent );
|
return ContentHandler::getContentText( $newContent );
|
||||||
}
|
}
|
||||||
|
|
@ -1500,7 +1504,7 @@ class WikiPage implements Page, IDBAccessObject {
|
||||||
/**
|
/**
|
||||||
* Returns true if this page's content model supports sections.
|
* Returns true if this page's content model supports sections.
|
||||||
*
|
*
|
||||||
* @return boolean whether sections are supported.
|
* @return bool
|
||||||
*
|
*
|
||||||
* @todo The skin should check this and not offer section functionality if sections are not supported.
|
* @todo The skin should check this and not offer section functionality if sections are not supported.
|
||||||
* @todo The EditPage should check this and not offer section functionality if sections are not supported.
|
* @todo The EditPage should check this and not offer section functionality if sections are not supported.
|
||||||
|
|
@ -1510,17 +1514,18 @@ class WikiPage implements Page, IDBAccessObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $section null|bool|int or a section number (0, 1, 2, T1, T2...)
|
* @param mixed $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
|
||||||
* @param $sectionContent Content: new content of the section
|
* @param Content $sectionContent New content of the section.
|
||||||
* @param string $sectionTitle new section's subject, only if $section is 'new'
|
* @param string $sectionTitle New section's subject, only if $section is "new".
|
||||||
* @param string $edittime revision timestamp or null to use the current revision
|
* @param string $edittime Revision timestamp or null to use the current revision.
|
||||||
*
|
*
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
* @return Content new complete article content, or null if error
|
* @return Content New complete article content, or null if error.
|
||||||
*
|
*
|
||||||
* @since 1.21
|
* @since 1.21
|
||||||
*/
|
*/
|
||||||
public function replaceSectionContent( $section, Content $sectionContent, $sectionTitle = '', $edittime = null ) {
|
public function replaceSectionContent( $section, Content $sectionContent, $sectionTitle = '',
|
||||||
|
$edittime = null ) {
|
||||||
wfProfileIn( __METHOD__ );
|
wfProfileIn( __METHOD__ );
|
||||||
|
|
||||||
if ( strval( $section ) == '' ) {
|
if ( strval( $section ) == '' ) {
|
||||||
|
|
@ -1529,7 +1534,8 @@ class WikiPage implements Page, IDBAccessObject {
|
||||||
} else {
|
} else {
|
||||||
if ( !$this->supportsSections() ) {
|
if ( !$this->supportsSections() ) {
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() );
|
throw new MWException( "sections not supported for content model " .
|
||||||
|
$this->getContentHandler()->getModelID() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bug 30711: always use current version when adding a new section
|
// Bug 30711: always use current version when adding a new section
|
||||||
|
|
@ -2612,9 +2618,11 @@ class WikiPage implements Page, IDBAccessObject {
|
||||||
/**
|
/**
|
||||||
* Take an array of page restrictions and flatten it to a string
|
* Take an array of page restrictions and flatten it to a string
|
||||||
* suitable for insertion into the page_restrictions field.
|
* suitable for insertion into the page_restrictions field.
|
||||||
* @param $limit Array
|
*
|
||||||
|
* @param string[] $limit
|
||||||
|
*
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected static function flattenRestrictions( $limit ) {
|
protected static function flattenRestrictions( $limit ) {
|
||||||
if ( !is_array( $limit ) ) {
|
if ( !is_array( $limit ) ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue