Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/files_sharing/lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ protected function parseShareExpiration(IShare $share, INotification $notificati
[
'node' => [
'type' => 'file',
'id' => $node->getId(),
'id' => (string)$node->getId(),
'name' => $node->getName(),
'path' => $path,
'path' => (string)$path,
],
]
);
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Activity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function getRichSubject(): string {
}

/**
* @return array[]
* @return array<string, array<string, string>>
* @since 11.0.0
*/
public function getRichSubjectParameters(): array {
Expand Down Expand Up @@ -335,7 +335,7 @@ public function getRichMessage(): string {
}

/**
* @return array[]
* @return array<string, array<string, string>>
* @since 11.0.0
*/
public function getRichMessageParameters(): array {
Expand Down
9 changes: 9 additions & 0 deletions lib/private/RichObjectStrings/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ protected function validateParameter(array $parameter) {
if (!empty($missingKeys)) {
throw new InvalidObjectExeption('Object is invalid, missing keys:'.json_encode($missingKeys));
}

foreach ($parameter as $key => $value) {
if (!is_string($key)) {
throw new InvalidObjectExeption('Object is invalid, key ' . $key . ' is not a string');
}
if (!is_string($value)) {
throw new InvalidObjectExeption('Object is invalid, value ' . $value . ' is not a string');
}
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/public/Activity/IEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getParsedSubject(): string;
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $subject
* @param array $parameters
* @param array<string, array<string, string>> $parameters
* @return $this
* @throws InvalidValueException if the subject or parameters are invalid
* @since 11.0.0
Expand All @@ -136,7 +136,7 @@ public function setRichSubject(string $subject, array $parameters = []): self;
public function getRichSubject(): string;

/**
* @return array[]
* @return array<string, array<string, string>>
* @since 11.0.0
*/
public function getRichSubjectParameters(): array;
Expand Down Expand Up @@ -187,7 +187,7 @@ public function getParsedMessage(): string;
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $message
* @param array $parameters
* @param array<string, array<string, string>> $parameters
* @return $this
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 11.0.0
Expand All @@ -202,7 +202,7 @@ public function setRichMessage(string $message, array $parameters = []): self;
public function getRichMessage(): string;

/**
* @return array[]
* @return array<string, array<string, string>>
* @since 11.0.0
*/
public function getRichMessageParameters(): array;
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Notification/INotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function getParsedSubject(): string;
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $subject
* @param array $parameters
* @param array<string, array<string, string>> $parameters
* @return $this
* @throws InvalidValueException if the subject or parameters are invalid
* @since 11.0.0
Expand Down Expand Up @@ -213,7 +213,7 @@ public function getParsedMessage(): string;
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $message
* @param array $parameters
* @param array<string, array<string, string>> $parameters
* @return $this
* @throws InvalidValueException if the message or parameters are invalid
* @since 11.0.0
Expand Down
1 change: 1 addition & 0 deletions lib/public/SetupCheck/SetupResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SetupResult implements \JsonSerializable {
/**
* @brief Private constructor, use success()/info()/warning()/error() instead
* @param self::SUCCESS|self::INFO|self::WARNING|self::ERROR $severity
* @param array<string, array<string, string>> $descriptionParameters
* @throws \OCP\RichObjectStrings\InvalidObjectExeption
* @since 28.0.0
* @since 28.0.2 Optional parameter ?array $descriptionParameters
Expand Down
23 changes: 23 additions & 0 deletions tests/lib/RichObjectStrings/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use OC\RichObjectStrings\Validator;
use OCP\RichObjectStrings\Definitions;
use OCP\RichObjectStrings\InvalidObjectExeption;
use Test\TestCase;

class ValidatorTest extends TestCase {
Expand All @@ -33,5 +34,27 @@ public function test() {
],
]);
$this->addToAssertionCount(2);

$this->expectException(InvalidObjectExeption::class);

$this->expectExceptionMessage('Object is invalid, value 123 is not a string');
$v->validate('test {string1} test.', [
'string1' => [
'type' => 'user',
'id' => 'johndoe',
'name' => 'John Doe',
'key' => 123,
],
]);

$this->expectExceptionMessage('Object is invalid, key 456 is not a string');
$v->validate('test {string1} test.', [
'string1' => [
'type' => 'user',
'id' => 'johndoe',
'name' => 'John Doe',
456 => 'value',
],
]);
}
}