Issues (210)

src/EventDispatcher/Event.php (3 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace JMS\Serializer\EventDispatcher;
6
7
use JMS\Serializer\Context;
8
use JMS\Serializer\Type\Type;
9
use JMS\Serializer\VisitorInterface;
10
11
/**
12
 * @phpstan-import-type TypeArray from Type
13
 */
14
class Event
15
{
16
    /**
17
     * @var bool Whether no further event listeners should be triggered
18
     */
19
    private $propagationStopped = false;
20 242
21
    /**
22 242
     * @var TypeArray
0 ignored issues
show
The type JMS\Serializer\EventDispatcher\TypeArray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23 242
     */
24 242
    protected $type;
25
26 2
    /**
27
     * @var Context
28 2
     */
29
    private $context;
30
31 18
    /**
32
     * @param TypeArray $type
33 18
     */
34
    public function __construct(Context $context, array $type)
35
    {
36 216
        $this->context = $context;
37
        $this->type = $type;
0 ignored issues
show
Documentation Bug introduced by
It seems like $type of type array is incompatible with the declared type JMS\Serializer\EventDispatcher\TypeArray of property $type.

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...
38 216
    }
39
40
    public function getVisitor(): VisitorInterface
41
    {
42
        return $this->context->getVisitor();
43
    }
44
45
    public function getContext(): Context
46
    {
47
        return $this->context;
48 28
    }
49
50 28
    public function getType(): array
51
    {
52
        return $this->type;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->type returns the type JMS\Serializer\EventDispatcher\TypeArray which is incompatible with the type-hinted return array.
Loading history...
53
    }
54
55
    /**
56
     * Returns whether further event listeners should be triggered.
57
     *
58
     * @see Event::stopPropagation()
59
     *
60 10
     * @return bool Whether propagation was already stopped for this event
61
     */
62 10
    public function isPropagationStopped(): bool
63 10
    {
64
        return $this->propagationStopped;
65
    }
66
67
    /**
68
     * Stops the propagation of the event to further event listeners.
69
     *
70
     * If multiple event listeners are connected to the same event, no
71
     * further event listener will be triggered once any trigger calls
72
     * stopPropagation().
73
     */
74
    public function stopPropagation(): void
75
    {
76
        $this->propagationStopped = true;
77
    }
78
}
79