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.
Completed
Push — master ( af8a26...45e031 )
by Yann
14s
created

EventSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace spec\Knp\Rad\DomainEvent;
4
5
use PhpSpec\ObjectBehavior;
6
7
class EventSpec extends ObjectBehavior
8
{
9
    function let()
10
    {
11
        $this->beConstructedWith('SomeEventName', [
12
            'first_prop' => 3,
13
            'second_prop' => 'lorem',
14
        ]);
15
    }
16
17
    function it_tells_if_a_property_exists()
18
    {
19
        $this->has('first_prop')->shouldReturn(true);
20
        $this->has('second_prop')->shouldReturn(true);
21
        $this->has('third_prop')->shouldReturn(false);
22
    }
23
24
    function it_throws_an_exception_if_the_property_does_not_exist()
25
    {
26
        $this->__get('first_prop')->shouldReturn(3);
27
        $this->first_prop->shouldReturn(3);
0 ignored issues
show
Documentation introduced by
The property first_prop does not exist on object<spec\Knp\Rad\DomainEvent\EventSpec>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
28
29
        $this
30
            ->shouldThrow(new \RuntimeException(
31
                'Property third_prop does not exist on event SomeEventName'
32
            ))
33
            ->during('__get', ['third_prop'])
34
        ;
35
    }
36
}
37