aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-06-12 14:40:42 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-06-13 14:58:38 +0200
commite9351ef779ea8e462062eaeb3e1824fe66829f7d (patch)
treebbb3424408068cb6826853b494321d35ba8f800b /lib
parent7382655a2c5a613cc923e9abd8142119d9de8d5c (diff)
downloadnextcloud-server-e9351ef779ea8e462062eaeb3e1824fe66829f7d.tar.gz
nextcloud-server-e9351ef779ea8e462062eaeb3e1824fe66829f7d.zip
Add strict type on Notifications tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Notification/Notification.php40
-rw-r--r--lib/public/Notification/INotification.php18
2 files changed, 29 insertions, 29 deletions
diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php
index ff3826047dd..47f415d15d3 100644
--- a/lib/private/Notification/Notification.php
+++ b/lib/private/Notification/Notification.php
@@ -135,7 +135,7 @@ class Notification implements INotification {
* @since 8.2.0
*/
public function setApp(string $app) {
- if (!is_string($app) || $app === '' || isset($app[32])) {
+ if (trim($app) === '' || isset($app[32])) {
throw new \InvalidArgumentException('The given app name is invalid');
}
$this->app = $app;
@@ -157,7 +157,7 @@ class Notification implements INotification {
* @since 8.2.0
*/
public function setUser(string $user) {
- if (!is_string($user) || $user === '' || isset($user[64])) {
+ if (trim($user) === '' || isset($user[64])) {
throw new \InvalidArgumentException('The given user id is invalid');
}
$this->user = $user;
@@ -201,8 +201,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the object type or id is invalid
* @since 8.2.0 - 9.0.0: Type of $id changed to string
*/
- public function setObject($type, $id) {
- if (!is_string($type) || $type === '' || isset($type[64])) {
+ public function setObject(string $type, $id) {
+ if (trim($type) === '' || isset($type[64])) {
throw new \InvalidArgumentException('The given object type is invalid');
}
$this->objectType = $type;
@@ -237,8 +237,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 8.2.0
*/
- public function setSubject($subject, array $parameters = []) {
- if (!is_string($subject) || $subject === '' || isset($subject[64])) {
+ public function setSubject(string $subject, array $parameters = []) {
+ if (trim($subject) === '' || isset($subject[64])) {
throw new \InvalidArgumentException('The given subject is invalid');
}
@@ -270,8 +270,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the subject is invalid
* @since 8.2.0
*/
- public function setParsedSubject($subject) {
- if (!is_string($subject) || $subject === '') {
+ public function setParsedSubject(string $subject) {
+ if (trim($subject) === '') {
throw new \InvalidArgumentException('The given parsed subject is invalid');
}
$this->subjectParsed = $subject;
@@ -293,8 +293,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 11.0.0
*/
- public function setRichSubject($subject, array $parameters = []) {
- if (!is_string($subject) || $subject === '') {
+ public function setRichSubject(string $subject, array $parameters = []) {
+ if (trim($subject) === '') {
throw new \InvalidArgumentException('The given parsed subject is invalid');
}
@@ -327,8 +327,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 8.2.0
*/
- public function setMessage($message, array $parameters = []) {
- if (!is_string($message) || $message === '' || isset($message[64])) {
+ public function setMessage(string $message, array $parameters = []) {
+ if (trim($message) === '' || isset($message[64])) {
throw new \InvalidArgumentException('The given message is invalid');
}
@@ -360,8 +360,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the message is invalid
* @since 8.2.0
*/
- public function setParsedMessage($message) {
- if (!is_string($message) || $message === '') {
+ public function setParsedMessage(string $message) {
+ if (trim($message) === '') {
throw new \InvalidArgumentException('The given parsed message is invalid');
}
$this->messageParsed = $message;
@@ -383,8 +383,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 11.0.0
*/
- public function setRichMessage($message, array $parameters = []) {
- if (!is_string($message) || $message === '') {
+ public function setRichMessage(string $message, array $parameters = []) {
+ if (trim($message) === '') {
throw new \InvalidArgumentException('The given parsed message is invalid');
}
@@ -416,8 +416,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the link is invalid
* @since 8.2.0
*/
- public function setLink($link) {
- if (!is_string($link) || $link === '' || isset($link[4000])) {
+ public function setLink(string $link) {
+ if (trim($link) === '' || isset($link[4000])) {
throw new \InvalidArgumentException('The given link is invalid');
}
$this->link = $link;
@@ -438,8 +438,8 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the icon is invalid
* @since 11.0.0
*/
- public function setIcon($icon) {
- if (!is_string($icon) || $icon === '' || isset($icon[4000])) {
+ public function setIcon(string $icon) {
+ if (trim($icon) === '' || isset($icon[4000])) {
throw new \InvalidArgumentException('The given icon is invalid');
}
$this->icon = $icon;
diff --git a/lib/public/Notification/INotification.php b/lib/public/Notification/INotification.php
index f71d0c53cc8..f7400e4778b 100644
--- a/lib/public/Notification/INotification.php
+++ b/lib/public/Notification/INotification.php
@@ -80,7 +80,7 @@ interface INotification {
* @throws \InvalidArgumentException if the object type or id is invalid
* @since 9.0.0
*/
- public function setObject($type, $id);
+ public function setObject(string $type, $id);
/**
* @return string
@@ -101,7 +101,7 @@ interface INotification {
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 9.0.0
*/
- public function setSubject($subject, array $parameters = []);
+ public function setSubject(string $subject, array $parameters = []);
/**
* @return string
@@ -132,7 +132,7 @@ interface INotification {
* @throws \InvalidArgumentException if the subject is invalid
* @since 9.0.0
*/
- public function setParsedSubject($subject);
+ public function setParsedSubject(string $subject);
/**
* @return string
@@ -157,7 +157,7 @@ interface INotification {
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 11.0.0
*/
- public function setRichSubject($subject, array $parameters = []);
+ public function setRichSubject(string $subject, array $parameters = []);
/**
* @return string
@@ -178,7 +178,7 @@ interface INotification {
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 9.0.0
*/
- public function setMessage($message, array $parameters = []);
+ public function setMessage(string $message, array $parameters = []);
/**
* @return string
@@ -209,7 +209,7 @@ interface INotification {
* @throws \InvalidArgumentException if the message is invalid
* @since 9.0.0
*/
- public function setParsedMessage($message);
+ public function setParsedMessage(string $message);
/**
* @return string
@@ -234,7 +234,7 @@ interface INotification {
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 11.0.0
*/
- public function setRichMessage($message, array $parameters = []);
+ public function setRichMessage(string $message, array $parameters = []);
/**
* @return string
@@ -254,7 +254,7 @@ interface INotification {
* @throws \InvalidArgumentException if the link is invalid
* @since 9.0.0
*/
- public function setLink($link);
+ public function setLink(string $link);
/**
* @return string
@@ -268,7 +268,7 @@ interface INotification {
* @throws \InvalidArgumentException if the icon is invalid
* @since 11.0.0
*/
- public function setIcon($icon);
+ public function setIcon(string $icon);
/**
* @return string