Skip to content

Commit 3845eec

Browse files
committed
Fix outdated code
Missing return type for `getTitle()` and `getLink()`
1 parent 1fae129 commit 3845eec

File tree

7 files changed

+43
-26
lines changed

7 files changed

+43
-26
lines changed

snippets/php/api/user_notifications/FooUserNotificationEvent.class.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
2+
23
namespace example\system\user\notification\event;
4+
35
use example\system\cache\runtime\BazRuntimeCache;
46
use example\system\user\notification\object\FooUserNotificationObject;
57
use wcf\system\email\Email;
@@ -16,7 +18,8 @@
1618
*
1719
* @method FooUserNotificationObject getUserNotificationObject()
1820
*/
19-
class FooUserNotificationEvent extends AbstractSharedUserNotificationEvent {
21+
class FooUserNotificationEvent extends AbstractSharedUserNotificationEvent
22+
{
2023
/**
2124
* @inheritDoc
2225
*/
@@ -26,7 +29,8 @@ class FooUserNotificationEvent extends AbstractSharedUserNotificationEvent {
2629
/**
2730
* @inheritDoc
2831
*/
29-
public function checkAccess() {
32+
public function checkAccess()
33+
{
3034
$this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));
3135

3236
if (!$this->getUserNotificationObject()->isAccessible()) {
@@ -42,15 +46,16 @@ public function checkAccess() {
4246
/**
4347
* @inheritDoc
4448
*/
45-
public function getEmailMessage($notificationType = 'instant') {
49+
public function getEmailMessage($notificationType = 'instant')
50+
{
4651
$this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));
4752

48-
$messageID = '<com.woltlab.example.baz/'.$this->getUserNotificationObject()->bazID.'@'.Email::getHost().'>';
53+
$messageID = '<com.woltlab.example.baz/' . $this->getUserNotificationObject()->bazID . '@' . Email::getHost() . '>';
4954

5055
return [
5156
'application' => 'example',
5257
'in-reply-to' => [$messageID],
53-
'message-id' => 'com.woltlab.example.foo/'.$this->getUserNotificationObject()->fooID,
58+
'message-id' => 'com.woltlab.example.foo/' . $this->getUserNotificationObject()->fooID,
5459
'references' => [$messageID],
5560
'template' => 'email_notification_foo'
5661
];
@@ -60,7 +65,8 @@ public function getEmailMessage($notificationType = 'instant') {
6065
* @inheritDoc
6166
* @since 5.0
6267
*/
63-
public function getEmailTitle() {
68+
public function getEmailTitle()
69+
{
6470
$this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));
6571

6672
return $this->getLanguage()->getDynamicVariable('example.foo.notification.mail.title', [
@@ -72,14 +78,16 @@ public function getEmailTitle() {
7278
/**
7379
* @inheritDoc
7480
*/
75-
public function getEventHash() {
81+
public function getEventHash()
82+
{
7683
return sha1($this->eventID . '-' . $this->getUserNotificationObject()->bazID);
7784
}
7885

7986
/**
8087
* @inheritDoc
8188
*/
82-
public function getLink() {
89+
public function getLink(): string
90+
{
8391
return LinkHandler::getInstance()->getLink('Foo', [
8492
'application' => 'example',
8593
'object' => $this->getUserNotificationObject()->getDecoratedObject()
@@ -89,7 +97,8 @@ public function getLink() {
8997
/**
9098
* @inheritDoc
9199
*/
92-
public function getMessage() {
100+
public function getMessage()
101+
{
93102
$authors = $this->getAuthors();
94103
$count = count($authors);
95104

@@ -118,7 +127,8 @@ public function getMessage() {
118127
/**
119128
* @inheritDoc
120129
*/
121-
public function getTitle() {
130+
public function getTitle(): string
131+
{
122132
$count = count($this->getAuthors());
123133
if ($count > 1) {
124134
return $this->getLanguage()->getDynamicVariable('example.foo.notification.title.stacked', [
@@ -133,7 +143,8 @@ public function getTitle() {
133143
/**
134144
* @inheritDoc
135145
*/
136-
protected function prepare() {
146+
protected function prepare()
147+
{
137148
BazRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->bazID);
138149
}
139-
}
150+
}

snippets/php/api/user_notifications/FooUserNotificationObject.class.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
2+
23
namespace example\system\user\notification\object;
4+
35
use example\data\foo\Foo;
46
use wcf\data\DatabaseObjectDecorator;
57
use wcf\system\user\notification\object\IUserNotificationObject;
@@ -15,7 +17,8 @@
1517
* @method Foo getDecoratedObject()
1618
* @mixin Foo
1719
*/
18-
class FooUserNotificationObject extends DatabaseObjectDecorator implements IUserNotificationObject {
20+
class FooUserNotificationObject extends DatabaseObjectDecorator implements IUserNotificationObject
21+
{
1922
/**
2023
* @inheritDoc
2124
*/
@@ -24,21 +27,24 @@ class FooUserNotificationObject extends DatabaseObjectDecorator implements IUser
2427
/**
2528
* @inheritDoc
2629
*/
27-
public function getTitle() {
30+
public function getTitle(): string
31+
{
2832
return $this->getDecoratedObject()->getTitle();
2933
}
3034

3135
/**
3236
* @inheritDoc
3337
*/
34-
public function getURL() {
38+
public function getURL()
39+
{
3540
return $this->getDecoratedObject()->getLink();
3641
}
3742

3843
/**
3944
* @inheritDoc
4045
*/
41-
public function getAuthorID() {
46+
public function getAuthorID()
47+
{
4248
return $this->getDecoratedObject()->userID;
4349
}
44-
}
50+
}

snippets/tutorial/tutorial-series/part-1/files/lib/data/person/Person.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __toString()
3232
/**
3333
* @inheritDoc
3434
*/
35-
public function getTitle()
35+
public function getTitle(): string
3636
{
3737
return $this->firstName . ' ' . $this->lastName;
3838
}

snippets/tutorial/tutorial-series/part-3/files/lib/data/person/Person.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __toString()
3535
/**
3636
* @inheritDoc
3737
*/
38-
public function getLink()
38+
public function getLink(): string
3939
{
4040
return LinkHandler::getInstance()->getControllerLink(PersonPage::class, [
4141
'object' => $this,
@@ -45,7 +45,7 @@ public function getLink()
4545
/**
4646
* @inheritDoc
4747
*/
48-
public function getTitle()
48+
public function getTitle(): string
4949
{
5050
return $this->firstName . ' ' . $this->lastName;
5151
}

snippets/tutorial/tutorial-series/part-4/files/lib/data/person/Person.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __toString()
3535
/**
3636
* @inheritDoc
3737
*/
38-
public function getLink()
38+
public function getLink(): string
3939
{
4040
return LinkHandler::getInstance()->getControllerLink(PersonPage::class, [
4141
'object' => $this,
@@ -45,7 +45,7 @@ public function getLink()
4545
/**
4646
* @inheritDoc
4747
*/
48-
public function getTitle()
48+
public function getTitle(): string
4949
{
5050
return $this->firstName . ' ' . $this->lastName;
5151
}

snippets/tutorial/tutorial-series/part-5/files/lib/data/person/Person.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __toString()
4444
/**
4545
* @inheritDoc
4646
*/
47-
public function getLink()
47+
public function getLink(): string
4848
{
4949
return LinkHandler::getInstance()->getControllerLink(PersonPage::class, [
5050
'object' => $this,
@@ -77,7 +77,7 @@ public function getInformation(): array
7777
/**
7878
* @inheritDoc
7979
*/
80-
public function getTitle()
80+
public function getTitle(): string
8181
{
8282
return $this->firstName . ' ' . $this->lastName;
8383
}

snippets/tutorial/tutorial-series/part-6/files/lib/data/person/Person.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __toString()
4444
/**
4545
* @inheritDoc
4646
*/
47-
public function getLink()
47+
public function getLink(): string
4848
{
4949
return LinkHandler::getInstance()->getControllerLink(PersonPage::class, [
5050
'object' => $this,
@@ -77,7 +77,7 @@ public function getInformation(): array
7777
/**
7878
* @inheritDoc
7979
*/
80-
public function getTitle()
80+
public function getTitle(): string
8181
{
8282
return $this->firstName . ' ' . $this->lastName;
8383
}

0 commit comments

Comments
 (0)