Skip to content

Commit 90e3f74

Browse files
committed
docs: update wrong php types in \InfluxDB2\Point
1 parent f72f191 commit 90e3f74

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## 3.5.0 [unreleased]
2+
### Others
3+
1. Update wrong php types in \InfluxDB2\Point
24

35
## 3.4.0 [2023-07-28]
46

src/InfluxDB2/Point.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ class Point
1515
private $tags;
1616
/** @var array */
1717
private $fields;
18-
/** @var int */
18+
/** @var int|null */
1919
private $time;
20-
/** @var WritePrecision */
20+
/** @var WritePrecision::* */
2121
private $precision;
2222

2323
/** Create DataPoint instance for specified measurement name.
2424
*
25-
* @param [String] name the measurement name for the point.
26-
* @param [Array] tags the tag set for the point
27-
* @param [Array] fields the fields for the point
28-
* @param [Integer] time the timestamp for the point
29-
* @param [WritePrecision] precision the precision for the unix timestamps within the body line-protocol
25+
* @param string $name the measurement name for the point.
26+
* @param array $tags the tag set for the point
27+
* @param array $fields the fields for the point
28+
* @param int $time the timestamp for the point
29+
* @param WritePrecision::* $precision the precision for the unix timestamps within the body line-protocol
3030
*/
3131
public function __construct(
3232
$name,
@@ -43,7 +43,7 @@ public function __construct(
4343
}
4444

4545
/**
46-
* @return WritePrecision
46+
* @return WritePrecision::*
4747
*/
4848
public function getPrecision(): ?string
4949
{
@@ -55,12 +55,10 @@ public static function measurement($name): Point
5555
return new Point($name);
5656
}
5757

58-
/** Create DataPoint instance from specified data.
59-
*
60-
* @param [Array] data
61-
* @return Point
58+
/**
59+
* Create DataPoint instance from specified data.
6260
*/
63-
public static function fromArray($data): ?Point
61+
public static function fromArray(array $data): ?Point
6462
{
6563
if (!array_key_exists('name', $data)) {
6664
return null;
@@ -76,8 +74,8 @@ public static function fromArray($data): ?Point
7674

7775
/** Adds or replaces a tag value for a point.
7876
*
79-
* @param [Object] key the tag name
80-
* @param [Object] value the tag value
77+
* @param mixed $key the tag name
78+
* @param mixed $value the tag value
8179
* @return Point
8280
*/
8381
public function addTag($key, $value): Point
@@ -89,8 +87,8 @@ public function addTag($key, $value): Point
8987

9088
/** Adds or replaces a field value for a point.
9189
*
92-
* @param [Object] key the tag name
93-
* @param [Object] value the tag value
90+
* @param mixed $key the tag name
91+
* @param mixed $value the tag value
9492
* @return Point
9593
*/
9694
public function addField($key, $value): Point
@@ -102,8 +100,8 @@ public function addField($key, $value): Point
102100

103101
/** Updates the timestamp for the point.
104102
*
105-
* @param [Object] time the timestamp
106-
* @param [WritePrecision] precision the timestamp precision
103+
* @param mixed $time the timestamp
104+
* @param WritePrecision::* $precision the timestamp precision
107105
* @return Point
108106
*/
109107
public function time($time, $precision = null): Point
@@ -116,9 +114,9 @@ public function time($time, $precision = null): Point
116114

117115
/** If there is no field then return null.
118116
*
119-
* @return string representation of the point
117+
* @return string|null representation of the point
120118
*/
121-
public function toLineProtocol()
119+
public function toLineProtocol(): ?string
122120
{
123121
$measurement = $this->escapeKey($this->name, false);
124122

@@ -149,7 +147,7 @@ public function toLineProtocol()
149147
return $lineProtocol;
150148
}
151149

152-
private function appendTags()
150+
private function appendTags(): ?string
153151
{
154152
$tags = '';
155153

@@ -173,7 +171,7 @@ private function appendTags()
173171
return $tags;
174172
}
175173

176-
private function appendFields()
174+
private function appendFields(): ?string
177175
{
178176
$fields = '';
179177

@@ -208,7 +206,7 @@ private function appendFields()
208206
return rtrim($fields, ',');
209207
}
210208

211-
private function appendTime()
209+
private function appendTime(): ?string
212210
{
213211
if (!isset($this->time)) {
214212
return null;
@@ -240,7 +238,7 @@ private function appendTime()
240238
return ' ' . $time;
241239
}
242240

243-
private function escapeKey($key, $escapeEqual = true)
241+
private function escapeKey($key, $escapeEqual = true): string
244242
{
245243
$escapeKeys = array(' ' => '\\ ', ',' => '\\,', "\\" => '\\\\',
246244
"\n" => '\\n', "\r" => '\\r', "\t" => '\\t');
@@ -252,13 +250,13 @@ private function escapeKey($key, $escapeEqual = true)
252250
return strtr($key, $escapeKeys);
253251
}
254252

255-
private function escapeValue($value)
253+
private function escapeValue($value): string
256254
{
257255
$escapeValues = array('"' => '\\"', "\\" => '\\\\');
258256
return strtr($value, $escapeValues);
259257
}
260258

261-
private function isNullOrEmptyString($str)
259+
private function isNullOrEmptyString($str): bool
262260
{
263261
return (!is_string($str) || trim($str) === '');
264262
}

0 commit comments

Comments
 (0)