summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Echo/includes/DataOutputFormatter.php')
-rw-r--r--Echo/includes/DataOutputFormatter.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/Echo/includes/DataOutputFormatter.php b/Echo/includes/DataOutputFormatter.php
index 7e0badd1..1b4abfd9 100644
--- a/Echo/includes/DataOutputFormatter.php
+++ b/Echo/includes/DataOutputFormatter.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\Revision\RevisionRecord;
+
/**
* Utility class that formats a notification in the format specified
*/
@@ -9,10 +11,10 @@ class EchoDataOutputFormatter {
* @var string[] type => class
*/
protected static $formatters = [
- 'flyout' => 'EchoFlyoutFormatter',
- 'model' => 'EchoModelFormatter',
- 'special' => 'SpecialNotificationsFormatter',
- 'html' => 'SpecialNotificationsFormatter',
+ 'flyout' => EchoFlyoutFormatter::class,
+ 'model' => EchoModelFormatter::class,
+ 'special' => SpecialNotificationsFormatter::class,
+ 'html' => SpecialNotificationsFormatter::class,
];
/**
@@ -31,14 +33,14 @@ class EchoDataOutputFormatter {
*/
public static function formatOutput(
EchoNotification $notification,
- $format = false,
+ $format,
User $user,
Language $lang
) {
$event = $notification->getEvent();
$timestamp = $notification->getTimestamp();
$utcTimestampIso8601 = wfTimestamp( TS_ISO_8601, $timestamp );
- $utcTimestampUnix = wfTimestamp( TS_UNIX, $timestamp );
+ $utcTimestampUnix = (int)wfTimestamp( TS_UNIX, $timestamp );
$utcTimestampMW = wfTimestamp( TS_MW, $timestamp );
$bundledIds = null;
@@ -57,7 +59,7 @@ class EchoDataOutputFormatter {
$timestampMw = self::getUserLocalTime( $user, $timestamp );
// Start creating date section header
- $now = wfTimestamp();
+ $now = (int)wfTimestamp();
$dateFormat = substr( $timestampMw, 0, 8 );
$timeDiff = $now - $utcTimestampUnix;
// Most notifications would be more than two days ago, check this
@@ -107,7 +109,7 @@ class EchoDataOutputFormatter {
if ( $title ) {
$output['title'] = [
'full' => $title->getPrefixedText(),
- 'namespace' => $title->getNSText(),
+ 'namespace' => $title->getNsText(),
'namespace-key' => $title->getNamespace(),
'text' => $title->getText(),
];
@@ -115,7 +117,7 @@ class EchoDataOutputFormatter {
$agent = $event->getAgent();
if ( $agent ) {
- if ( $event->userCan( Revision::DELETED_USER, $user ) ) {
+ if ( $event->userCan( RevisionRecord::DELETED_USER, $user ) ) {
$output['agent'] = [
'id' => $agent->getId(),
'name' => $agent->getName(),
@@ -185,9 +187,9 @@ class EchoDataOutputFormatter {
/** @var EchoEventFormatter $formatter */
$formatter = new $class( $user, $lang );
return $formatter->format( $event );
- } else {
- return false;
}
+
+ return false;
}
/**
@@ -208,7 +210,7 @@ class EchoDataOutputFormatter {
* Helper function for converting UTC timezone to a user's timezone
*
* @param User $user
- * @param string $ts
+ * @param string|int $ts
* @param int $format output format
*
* @return string