Completed
Push — master ( e2a85e...93e467 )
by Adam
01:43
created
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
require 'vendor/autoload.php';
4
5
6
//$service = new \PhpJsonRpc\Server\Service\Service('json-rpc-2.0/v1');
7
//
8
//$service->dispatch(
9
//    '{"jsonrpc": "2.0", "metXhod": "welcome", "params": {"name": "Adam", "age": 29}, "id": 1}'
10
//);
11
//
12
//return;
13
14
15
$server = new \PhpJsonRpc\Server\Server\Server();
16
17
$service = new \PhpJsonRpc\Server\Service\Service('json-rpc-2.0/v1');
18
$service->add(
19
    new \PhpJsonRpc\Server\Service\Method\Closure(
20
        'Company.Namespace.method_1',
21
        new \PhpJsonRpc\Server\Service\Method\Callables\CallableClosure(function() {
22
            //throw new \Exception('ajjaj');
23
            throw new \PhpJsonRpc\Server\Error\Exception\ExceptionWithData('ok');
24
25
            $a = new stdClass();
0 ignored issues
show
$a = new \stdClass(); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
26
            $a->b;
27
28
            return 'hali';
29
        })
30
    )
31
);
32
33
$server->addService($service);
34
35
//try {
36
    $server->handle(
37
        'json-rpc-2.0/v1',
38
        '{"jsonrpc": "2.0", "method": "Company.Namespace.method_1", "id": 1}'
39
    );
40
//} catch (\Exception $e) {
41
//    //echo 'hi';
42
//    throw $e;
43
//}
44
45
46
//        $runner = new Runner([new JsonFormatter()]);
47
//        $runner->treatErrorsAsExceptions(true);
48
//        $runner->register();