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 lib/private/Activity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Event implements IEvent {
protected $subjectParsed = '';
/** @var string */
protected $subjectRich = '';
/** @var array */
/** @var array<string, array<string, string>> */
protected $subjectRichParameters = [];
/** @var string */
protected $message = '';
Expand All @@ -44,7 +44,7 @@ class Event implements IEvent {
protected $messageParsed = '';
/** @var string */
protected $messageRich = '';
/** @var array */
/** @var array<string, array<string, string>> */
protected $messageRichParameters = [];
/** @var string */
protected $objectType = '';
Expand Down
10 changes: 5 additions & 5 deletions lib/private/RichObjectStrings/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public function validate(string $subject, array $parameters): void {
throw new InvalidObjectExeption('Parameter is malformed');
}

$this->validateParameter($parameter);
$this->validateParameter($placeholder, $parameter);
}
}

/**
* @param array $parameter
* @throws InvalidObjectExeption
*/
protected function validateParameter(array $parameter): void {
protected function validateParameter(string $placeholder, array $parameter): void {
if (!isset($parameter['type'])) {
throw new InvalidObjectExeption('Object type is undefined');
}
Expand All @@ -74,15 +74,15 @@ protected function validateParameter(array $parameter): void {

$missingKeys = array_diff($requiredParameters, array_keys($parameter));
if (!empty($missingKeys)) {
throw new InvalidObjectExeption('Object is invalid, missing keys:' . json_encode($missingKeys));
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' 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');
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string');
}
if (!is_string($value)) {
throw new InvalidObjectExeption('Object is invalid, value ' . $value . ' is not a string');
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, value ' . $value . ' for key ' . $key . ' is not a string');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/RichObjectStrings/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testValidate(): void {

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

$this->expectExceptionMessage('Object is invalid, value 123 is not a string');
$this->expectExceptionMessage('Object for placeholder string1 is invalid, value 123 for key key is not a string');
$v->validate('test {string1} test.', [
'string1' => [
'type' => 'user',
Expand All @@ -49,7 +49,7 @@ public function testValidate(): void {
],
]);

$this->expectExceptionMessage('Object is invalid, key 456 is not a string');
$this->expectExceptionMessage('Object for placeholder string1 is invalid, key 456 is not a string');
$v->validate('test {string1} test.', [
'string1' => [
'type' => 'user',
Expand Down
Loading