Skip to content

Commit 71f8c4d

Browse files
committed
fix(RichObjectStrings): Make exception messages for invalid parameters more useful for debugging
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 7bcaefd commit 71f8c4d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/private/Activity/Event.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Event implements IEvent {
3434
protected $subjectParsed = '';
3535
/** @var string */
3636
protected $subjectRich = '';
37-
/** @var array */
37+
/** @var array<string, array<string, string>> */
3838
protected $subjectRichParameters = [];
3939
/** @var string */
4040
protected $message = '';
@@ -44,7 +44,7 @@ class Event implements IEvent {
4444
protected $messageParsed = '';
4545
/** @var string */
4646
protected $messageRich = '';
47-
/** @var array */
47+
/** @var array<string, array<string, string>> */
4848
protected $messageRichParameters = [];
4949
/** @var string */
5050
protected $objectType = '';

lib/private/RichObjectStrings/Validator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function validate(string $subject, array $parameters): void {
6464
* @param array $parameter
6565
* @throws InvalidObjectExeption
6666
*/
67-
protected function validateParameter(array $parameter): void {
67+
protected function validateParameter(string $placeholder, array $parameter): void {
6868
if (!isset($parameter['type'])) {
6969
throw new InvalidObjectExeption('Object type is undefined');
7070
}
@@ -74,15 +74,15 @@ protected function validateParameter(array $parameter): void {
7474

7575
$missingKeys = array_diff($requiredParameters, array_keys($parameter));
7676
if (!empty($missingKeys)) {
77-
throw new InvalidObjectExeption('Object is invalid, missing keys:' . json_encode($missingKeys));
77+
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, missing keys:' . json_encode($missingKeys));
7878
}
7979

8080
foreach ($parameter as $key => $value) {
8181
if (!is_string($key)) {
82-
throw new InvalidObjectExeption('Object is invalid, key ' . $key . ' is not a string');
82+
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string');
8383
}
8484
if (!is_string($value)) {
85-
throw new InvalidObjectExeption('Object is invalid, value ' . $value . ' is not a string');
85+
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, value ' . $value . ' for key ' . $key . ' is not a string');
8686
}
8787
}
8888
}

0 commit comments

Comments
 (0)