Skip to content

Commit

Permalink
docs: update wrong php types in \InfluxDB2\Point
Browse files Browse the repository at this point in the history
  • Loading branch information
trandbert37 committed Aug 1, 2023
1 parent f72f191 commit 1c73dd1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 3.5.0 [unreleased]
### Others
1. [#148](https://github.com/influxdata/influxdb-client-php/pull/148): Update wrong php types in \InfluxDB2\Point

## 3.4.0 [2023-07-28]

Expand Down
52 changes: 25 additions & 27 deletions src/InfluxDB2/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ class Point
private $tags;
/** @var array */
private $fields;
/** @var int */
/** @var int|null */
private $time;
/** @var WritePrecision */
/** @var WritePrecision::* */
private $precision;

/** Create DataPoint instance for specified measurement name.
*
* @param [String] name the measurement name for the point.
* @param [Array] tags the tag set for the point
* @param [Array] fields the fields for the point
* @param [Integer] time the timestamp for the point
* @param [WritePrecision] precision the precision for the unix timestamps within the body line-protocol
* @param string $name the measurement name for the point.
* @param array $tags the tag set for the point
* @param array $fields the fields for the point
* @param int $time the timestamp for the point
* @param WritePrecision::* $precision the precision for the unix timestamps within the body line-protocol
*/
public function __construct(
$name,
Expand All @@ -43,7 +43,7 @@ public function __construct(
}

/**
* @return WritePrecision
* @return WritePrecision::*
*/
public function getPrecision(): ?string
{
Expand All @@ -55,12 +55,10 @@ public static function measurement($name): Point
return new Point($name);
}

/** Create DataPoint instance from specified data.
*
* @param [Array] data
* @return Point
/**
* Create DataPoint instance from specified data.
*/
public static function fromArray($data): ?Point
public static function fromArray(array $data): ?Point
{
if (!array_key_exists('name', $data)) {
return null;
Expand All @@ -76,8 +74,8 @@ public static function fromArray($data): ?Point

/** Adds or replaces a tag value for a point.
*
* @param [Object] key the tag name
* @param [Object] value the tag value
* @param mixed $key the tag name
* @param mixed $value the tag value
* @return Point
*/
public function addTag($key, $value): Point
Expand All @@ -89,8 +87,8 @@ public function addTag($key, $value): Point

/** Adds or replaces a field value for a point.
*
* @param [Object] key the tag name
* @param [Object] value the tag value
* @param mixed $key the tag name
* @param mixed $value the tag value
* @return Point
*/
public function addField($key, $value): Point
Expand All @@ -102,8 +100,8 @@ public function addField($key, $value): Point

/** Updates the timestamp for the point.
*
* @param [Object] time the timestamp
* @param [WritePrecision] precision the timestamp precision
* @param mixed $time the timestamp
* @param WritePrecision::* $precision the timestamp precision
* @return Point
*/
public function time($time, $precision = null): Point
Expand All @@ -116,9 +114,9 @@ public function time($time, $precision = null): Point

/** If there is no field then return null.
*
* @return string representation of the point
* @return string|null representation of the point
*/
public function toLineProtocol()
public function toLineProtocol(): ?string
{
$measurement = $this->escapeKey($this->name, false);

Expand Down Expand Up @@ -149,7 +147,7 @@ public function toLineProtocol()
return $lineProtocol;
}

private function appendTags()
private function appendTags(): ?string
{
$tags = '';

Expand All @@ -173,7 +171,7 @@ private function appendTags()
return $tags;
}

private function appendFields()
private function appendFields(): ?string
{
$fields = '';

Expand Down Expand Up @@ -208,7 +206,7 @@ private function appendFields()
return rtrim($fields, ',');
}

private function appendTime()
private function appendTime(): ?string
{
if (!isset($this->time)) {
return null;
Expand Down Expand Up @@ -240,7 +238,7 @@ private function appendTime()
return ' ' . $time;
}

private function escapeKey($key, $escapeEqual = true)
private function escapeKey($key, $escapeEqual = true): string
{
$escapeKeys = array(' ' => '\\ ', ',' => '\\,', "\\" => '\\\\',
"\n" => '\\n', "\r" => '\\r', "\t" => '\\t');
Expand All @@ -252,13 +250,13 @@ private function escapeKey($key, $escapeEqual = true)
return strtr($key, $escapeKeys);
}

private function escapeValue($value)
private function escapeValue($value): string
{
$escapeValues = array('"' => '\\"', "\\" => '\\\\');
return strtr($value, $escapeValues);
}

private function isNullOrEmptyString($str)
private function isNullOrEmptyString($str): bool
{
return (!is_string($str) || trim($str) === '');
}
Expand Down

0 comments on commit 1c73dd1

Please sign in to comment.