Skip to content

Commit

Permalink
add template phpdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Nov 22, 2024
1 parent d411663 commit b8cc3c0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions php/src/Google/Protobuf/RepeatedField.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
private $type;
/**
* @ignore
* @template T of object
* @type string|class-string<T>
*/
private $klass;
/**
Expand All @@ -45,8 +47,9 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Constructs an instance of RepeatedField.
*
* @template T of object
* @param integer $type Type of the stored element.
* @param string $klass Message/Enum class name (message/enum fields only).
* @param string|class-string<T> $klass Message/Enum class name (message/enum fields only).
* @ignore
*/
public function __construct($type, $klass = null)
Expand Down Expand Up @@ -75,6 +78,8 @@ public function getType()

/**
* @ignore
* @template T of object
* @return string|class-string<T>
*/
public function getClass()
{
Expand All @@ -94,8 +99,9 @@ public function getLegacyClass()
*
* This will also be called for: $ele = $arr[0]
*
* @template T of object
* @param integer $offset The index of the element to be fetched.
* @return mixed The stored element at given index.
* @return T The stored element at given index.
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
* @todo need to add return type mixed (require update php version to 8.0)
Expand All @@ -111,8 +117,9 @@ public function offsetGet($offset)
*
* This will also be called for: $arr []= $ele and $arr[0] = ele
*
* @template T of object
* @param int|null $offset The index of the element to be assigned.
* @param mixed $value The element to be assigned.
* @param T $value The element to be assigned.
* @return void
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
Expand Down

0 comments on commit b8cc3c0

Please sign in to comment.