From 023fe6ff4d541b6c21d8a3d039abf4a1f95c9dee Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 23 Feb 2022 10:26:32 -0800 Subject: [PATCH] chore: [PHP] fix phpdoc for MapField keys anything other than `string|int` is not a valid offset type. `bool` may be added, but it's not a true offset because it will be cast to an `int` if used: ```php $a = [false => '1' , true => '2']; $a[0] = '3'; $a[1] = '4'; var_dump($a); // array(2) { // [0]=> // string(1) "3" // [1]=> // string(1) "4" // } ``` --- php/src/Google/Protobuf/Internal/MapField.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php index d44377a17..d413c6d90 100644 --- a/php/src/Google/Protobuf/Internal/MapField.php +++ b/php/src/Google/Protobuf/Internal/MapField.php @@ -131,7 +131,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable * * This will also be called for: $ele = $arr[$key] * - * @param int|bool|string $key The key of the element to be fetched. + * @param int|string $key The key of the element to be fetched. * @return object The stored element at given key. * @throws \ErrorException Invalid type for index. * @throws \ErrorException Non-existing index. @@ -148,7 +148,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable * * This will also be called for: $arr[$key] = $value * - * @param object $key The key of the element to be fetched. + * @param int|string $key The key of the element to be fetched. * @param object $value The element to be assigned. * @return void * @throws \ErrorException Invalid type for key. @@ -211,7 +211,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable * * This will also be called for: unset($arr) * - * @param object $key The key of the element to be removed. + * @param int|string $key The key of the element to be removed. * @return void * @throws \ErrorException Invalid type for key. * @todo need to add return type void (require update php version to 7.1) @@ -228,7 +228,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable * * This will also be called for: isset($arr) * - * @param object $key The key of the element to be removed. + * @param int|string $key The key of the element to be removed. * @return bool True if the element at the given key exists. * @throws \ErrorException Invalid type for key. */