Skip to content

Commit b69cf85

Browse files
authored
Change return type to static in PendingMetric methods
This change allows type hints to work correctly when extending PendingMetric to add custom functions (especially useful if also using custom Metric models)
1 parent 13a838e commit b69cf85

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/PendingMetric.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ public function __construct(BackedEnum|string $name)
5656
/**
5757
* Create a new pending metric.
5858
*/
59-
public static function make(BackedEnum|string $name): self
59+
public static function make(BackedEnum|string $name): static
6060
{
61-
return new self($name);
61+
return new static($name);
6262
}
6363

6464
/**
6565
* Set the category of the metric.
6666
*/
67-
public function category(BackedEnum|string|null $category): self
67+
public function category(BackedEnum|string|null $category): static
6868
{
6969
$this->category = $category;
7070

@@ -74,7 +74,7 @@ public function category(BackedEnum|string|null $category): self
7474
/**
7575
* Set the date of the metric.
7676
*/
77-
public function date(CarbonInterface $date): self
77+
public function date(CarbonInterface $date): static
7878
{
7979
$this->date = $date;
8080

@@ -84,7 +84,7 @@ public function date(CarbonInterface $date): self
8484
/**
8585
* Set the measurable model of the metric.
8686
*/
87-
public function measurable(Model $measurable): self
87+
public function measurable(Model $measurable): static
8888
{
8989
$this->measurable = $measurable;
9090

@@ -94,7 +94,7 @@ public function measurable(Model $measurable): self
9494
/**
9595
* Set the metric model to use.
9696
*/
97-
public function model(string $model): self
97+
public function model(string $model): static
9898
{
9999
$this->model = $model;
100100

@@ -104,7 +104,7 @@ public function model(string $model): self
104104
/**
105105
* Enable hourly tracking for the metric.
106106
*/
107-
public function hourly(): self
107+
public function hourly(): static
108108
{
109109
$this->trackHourly = true;
110110

@@ -116,7 +116,7 @@ public function hourly(): self
116116
*
117117
* @param array<string, mixed> $attributes
118118
*/
119-
public function with(array $attributes): self
119+
public function with(array $attributes): static
120120
{
121121
$this->additional = $attributes;
122122

0 commit comments

Comments
 (0)