Add some missing typehints

Change-Id: Idb111dd907972d9e02dab4b26c3fc106b12b1035
This commit is contained in:
Ed Sanders 2022-06-28 18:34:17 +01:00 committed by Bartosz Dziewoński
parent dac8380021
commit 4accd2fc7e
4 changed files with 9 additions and 5 deletions

View file

@ -461,7 +461,9 @@ class CommentFormatter {
* @param UserIdentity $user
* @return string
*/
public static function getSignatureRelativeTime( MWTimestamp $timestamp, Language $lang, UserIdentity $user ) {
public static function getSignatureRelativeTime(
MWTimestamp $timestamp, Language $lang, UserIdentity $user
): string {
if ( time() - intval( $timestamp->getTimestamp() ) < 120 ) {
$timestamp = new MWTimestamp();
}

View file

@ -167,7 +167,7 @@ class CommentUtils {
* @param Node $node Node, should be a leaf node (a node with no children)
* @return bool
*/
public static function isCommentContent( Node $node ) {
public static function isCommentContent( Node $node ): bool {
return (
$node instanceof Text &&
static::htmlTrim( $node->nodeValue ?? '' ) !== ''

View file

@ -284,7 +284,7 @@ abstract class ThreadItem implements JsonSerializable {
* @param Element $node
* @return Title|null
*/
private function getSinglePageTransclusionTitle( Element $node ) {
private function getSinglePageTransclusionTitle( Element $node ): ?Title {
$dataMw = json_decode( $node->getAttribute( 'data-mw' ) ?? '', true );
// Only return a page name if this is a simple single-template transclusion.
@ -311,7 +311,7 @@ abstract class ThreadItem implements JsonSerializable {
* @param Element $startNode
* @return ImmutableRange
*/
private function getTransclusionRange( Element $startNode ) {
private function getTransclusionRange( Element $startNode ): ImmutableRange {
$endNode = $startNode;
while (
// Phan doesn't realize that the conditions on $nextSibling can terminate the loop

View file

@ -25,7 +25,9 @@ class MockCommentFormatter extends CommentFormatter {
/**
* @inheritDoc
*/
public static function getSignatureRelativeTime( MWTimestamp $timestamp, Language $lang, UserIdentity $user ) {
public static function getSignatureRelativeTime(
MWTimestamp $timestamp, Language $lang, UserIdentity $user
): string {
// Relative times can't be used in tests, so just return a plain timestamp
return $timestamp->getTimestamp();
}