Skip to content

Commit 788e535

Browse files
committed
Update to PHP 8.2
1 parent 50152f5 commit 788e535

File tree

108 files changed

+702
-1331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+702
-1331
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ composer.phar
44
/vendor/
55
docs/reactivex.github.io
66
build/
7+
.idea

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
],
2222
"require": {
23-
"php": ">=7.0.0",
23+
"php": ">=8.2",
2424
"react/promise": "^3 || ~2.2"
2525
},
2626
"require-dev": {

demo/create/createObservable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

33
use Rx\Disposable\CallbackDisposable;
4+
use Rx\Observable\AnonymousObservable;
5+
use Rx\ObserverInterface;
46

57
require_once __DIR__ . '/../bootstrap.php';
68

79
//With Class
8-
$source = new \Rx\Observable\AnonymousObservable(function (\Rx\ObserverInterface $observer) {
10+
$source = new AnonymousObservable(function (ObserverInterface $observer) {
911
$observer->onNext(42);
1012
$observer->onCompleted();
1113

demo/custom-operator/Rot13Operator.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ class Rot13Operator implements OperatorInterface
1515
public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface
1616
{
1717
return $observable->subscribe(
18-
function ($json) use ($observer) {
19-
$observer->onNext(str_rot13($json));
20-
},
21-
[$observer, 'onError'],
22-
[$observer, 'onCompleted']
18+
fn ($json) => $observer->onNext(str_rot13($json)),
19+
fn ($e) => $observer->onError($e),
20+
fn () => $observer->onCompleted()
2321
);
2422
}
2523
}

demo/zip/zip.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
function ($array) use ($observer) {
2121
$observer->onNext(json_encode($array));
2222
},
23-
[$observer, 'onError'],
24-
[$observer, 'onCompleted']
23+
fn ($e) => $observer->onError($e),
24+
fn () => $observer->onCompleted()
2525
));

src/Disposable/BinaryDisposable.php

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,16 @@
66

77
use Rx\DisposableInterface;
88

9-
/**
10-
* Class BinaryDisposable
11-
* @package Rx\Disposable
12-
*/
139
class BinaryDisposable implements DisposableInterface
1410
{
15-
/** @var \Rx\DisposableInterface */
16-
private $first;
17-
18-
/** @var \Rx\DisposableInterface */
19-
private $second;
20-
21-
/** @var bool */
22-
protected $isDisposed = false;
23-
24-
/**
25-
* BinaryDisposable constructor.
26-
* @param $first
27-
* @param $second
28-
*/
29-
public function __construct(DisposableInterface $first, DisposableInterface $second)
30-
{
31-
$this->first = $first;
32-
$this->second = $second;
11+
public function __construct(
12+
private null|DisposableInterface $first,
13+
private null|DisposableInterface $second,
14+
protected bool $isDisposed = false
15+
) {
3316
}
3417

35-
public function dispose()
18+
public function dispose(): void
3619
{
3720
if ($this->isDisposed) {
3821
return;

src/Disposable/CallbackDisposable.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88

99
class CallbackDisposable implements DisposableInterface
1010
{
11-
private $action;
12-
private $disposed = false;
13-
14-
public function __construct(callable $action)
15-
{
16-
$this->action = $action;
11+
public function __construct(
12+
private \Closure $action,
13+
private bool $disposed = false
14+
) {
1715
}
1816

19-
public function dispose()
17+
public function dispose(): void
2018
{
2119
if ($this->disposed) {
2220
return;

src/Disposable/CompositeDisposable.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
class CompositeDisposable implements DisposableInterface
1010
{
11-
private $disposables;
12-
private $isDisposed = false;
1311

14-
public function __construct(array $disposables = [])
15-
{
16-
$this->disposables = $disposables;
12+
public function __construct(
13+
private array $disposables = [],
14+
private bool $isDisposed = false
15+
) {
1716
}
1817

19-
public function dispose()
18+
public function dispose(): void
2019
{
2120
if ($this->isDisposed) {
2221
return;
@@ -32,7 +31,7 @@ public function dispose()
3231
}
3332
}
3433

35-
public function add(DisposableInterface $disposable)
34+
public function add(DisposableInterface $disposable): void
3635
{
3736
if ($this->isDisposed) {
3837
$disposable->dispose();
@@ -65,12 +64,12 @@ public function contains(DisposableInterface $disposable): bool
6564
return in_array($disposable, $this->disposables, true);
6665
}
6766

68-
public function count()
67+
public function count(): int
6968
{
7069
return count($this->disposables);
7170
}
7271

73-
public function clear()
72+
public function clear(): void
7473
{
7574
$disposables = $this->disposables;
7675
$this->disposables = [];

src/Disposable/EmptyDisposable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class EmptyDisposable implements DisposableInterface
1010
{
11-
public function dispose()
11+
public function dispose(): void
1212
{
1313
// do nothing \o/
1414
}

0 commit comments

Comments
 (0)