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.

NamedLetHandler::evaluate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 1
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Sphpeme\ExpHandler;
4
5
6
use Sphpeme\Env;
7
use Sphpeme\Evaluator;
8
use Sphpeme\Symbol;
9
10
class NamedLetHandler implements ExpHandler
11
{
12
13
14
    /** @var Symbol */
15
    private $letSymbol;
16
17 2
    public function __construct()
18
    {
19 2
        $this->letSymbol = Symbol::make('let');
0 ignored issues
show
Documentation Bug introduced by
It seems like \Sphpeme\Symbol::make('let') of type object<self> is incompatible with the declared type object<Sphpeme\Symbol> of property $letSymbol.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
20 2
    }
21
22 1
    public function handles($program): bool
23
    {
24 1
        return $program[0] === $this->letSymbol &&
25 1
            $program[1] instanceof Symbol;
26
    }
27
28 1
    public function evaluate($program, Env\EnvInterface $env, Evaluator $evaluate)
29
    {
30
        // generate a lambda (eval the program *without* name)
31
        // use that as the value in the define
32
        // then call that
33 1
        list($_let, $name, $bindings) = $program;
0 ignored issues
show
Unused Code introduced by
The assignment to $_let is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
34 1
        $body = \array_slice($program, 3);
35 1
        $lambdaExp = array_merge([Symbol::make('lambda'), array_column($bindings, 0)], $body);
36 1
        $defineExp = [Symbol::make('define'), $name, $lambdaExp];
37 1
        $evaluate($defineExp, $env);
38 1
        return $evaluate(array_merge([$name], array_column($bindings, 1)), $env);
39
    }
40
}