GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

functions.php ➔ observableFromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\Rx;
4
5
use Exception;
6
use React\EventLoop\LoopInterface;
7
use React\Promise\PromiseInterface;
8
use Rx\Observable;
9
use Rx\Scheduler;
10
use Throwable;
11
12
/**
13
 * Take an observable from a promise and return an new observable piping through the stream.
14
 *
15
 * @param  PromiseInterface $promise
16
 * @return Observable
17
 */
18
function unwrapObservableFromPromise(PromiseInterface $promise): Observable
19
{
20 3
    return Observable::fromPromise($promise)->mergeAll();
21
}
22
23
/**
24
 * Take an array and return an observable from it with an immediate scheduler for scheduling.
25
 *
26
 * @param  array      $array
27
 * @return Observable
28
 */
29
function observableFromArray(array $array): Observable
30
{
31 1
    return Observable::fromArray($array, Scheduler::getImmediate());
32
}
33
34
/**
35
 * @param  LoopInterface $loop
36
 * @throws Throwable
37
 */
38
function setAsyncScheduler(LoopInterface $loop): void
39
{
40
    try {
41
        Scheduler::setAsyncFactory(function () use ($loop) {
42 1
            return new Scheduler\EventLoopScheduler($loop);
0 ignored issues
show
Documentation introduced by
$loop is of type object<React\EventLoop\LoopInterface>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43 1
        });
44 1
    } catch (Exception $e) {
45 1
        if ($e->getMessage() === 'The async factory can not be set after the scheduler has been created') {
46 1
            return;
47
        }
48
49
        throw $e;
50
    }
51
}
52