Skip to content

Commit fa0ab33

Browse files
nicolas-grekaskelunikbwoebi
authored
Use str_increment() to fix PHP 8.5 deprecation (#456)
Also updates the GitHub action versions to fix the build. Co-authored-by: Niklas Keller <me@kelunik.com> Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
1 parent f0e3220 commit fa0ab33

5 files changed

Lines changed: 14 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
git config --global core.eol lf
4242
4343
- name: Checkout code
44-
uses: actions/checkout@v2
44+
uses: actions/checkout@v5
4545

4646
- name: Setup PHP
4747
uses: shivammathur/setup-php@v2
@@ -53,7 +53,7 @@ jobs:
5353
run: echo "::set-output name=dir::$(composer config cache-dir)"
5454

5555
- name: Cache dependencies
56-
uses: actions/cache@v2
56+
uses: actions/cache@v4
5757
with:
5858
path: ${{ steps.composer-cache.outputs.dir }}
5959
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}

psalm.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
</errorLevel>
1919
</StringIncrement>
2020

21+
<UndefinedFunction>
22+
<errorLevel type="suppress">
23+
<referencedFunction name="str_increment"/>
24+
</errorLevel>
25+
</UndefinedFunction>
26+
2127
<RedundantConditionGivenDocblockType>
2228
<errorLevel type="suppress">
2329
<directory name="src" />

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 ? self::$nextId = \str_increment(self::$nextId) : ++self::$nextId;
7172

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

0 commit comments

Comments
 (0)