Skip to content

Commit e828df8

Browse files
Use str_increment() to fix PHP 8.5 deprecation
1 parent f0e3220 commit e828df8

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/CompositeCancellation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public function __destruct()
6969

7070
public function subscribe(\Closure $callback): string
7171
{
72-
$id = $this->nextId++;
72+
$id = $this->nextId;
73+
\PHP_VERSION_ID >= 80300 ? $this->nextId = \str_increment($this->nextId) : ++$this->nextId;
7374

7475
if ($this->exception) {
7576
EventLoop::queue($callback, $this->exception);

src/Internal/Cancellable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ private function getException(): CancelledException
5858

5959
public function subscribe(\Closure $callback): string
6060
{
61-
$id = $this->nextId++;
61+
$id = $this->nextId;
62+
\PHP_VERSION_ID >= 80300 ? $this->nextId = \str_increment($this->nextId) : ++$this->nextId;
6263

6364
if ($this->requested) {
6465
$exception = $this->getException();

src/Internal/FutureState.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function __destruct()
6767
*/
6868
public function subscribe(\Closure $callback): string
6969
{
70-
$id = self::$nextId++;
70+
$id = self::$nextId;
71+
\PHP_VERSION_ID >= 80300 ? $this->nextId = \str_increment($this->nextId) : ++$this->nextId;
7172

7273
$this->handled = true; // Even if unsubscribed later, consider the future handled.
7374

0 commit comments

Comments
 (0)