1 | <?php |
||||
2 | |||||
3 | namespace Nip\Router\Router\Traits; |
||||
4 | |||||
5 | use Nip\Router\Route\Route; |
||||
6 | use Nip\Router\RouteCollection; |
||||
7 | |||||
8 | /** |
||||
9 | * Class HasRouteCollectionTrait |
||||
10 | * @package Nip\Router\Router\Traits |
||||
11 | */ |
||||
12 | trait HasRouteCollectionTrait |
||||
13 | { |
||||
14 | |||||
15 | /** |
||||
16 | * @inheritdoc |
||||
17 | * @return RouteCollection |
||||
18 | */ |
||||
19 | 7 | public function getRouteCollection() |
|||
20 | { |
||||
21 | // if (null === $this->collection) { |
||||
22 | // $this->collection = $this->newRoutesCollection(); |
||||
23 | // } |
||||
24 | 7 | return parent::getRouteCollection(); |
|||
25 | } |
||||
26 | |||||
27 | /** |
||||
28 | * @param $name |
||||
29 | * @return null|Route\Route |
||||
0 ignored issues
–
show
|
|||||
30 | */ |
||||
31 | 1 | public function getRoute($name) |
|||
32 | { |
||||
33 | 1 | return $this->getRouteCollection()->get($name); |
|||
34 | } |
||||
35 | |||||
36 | /** |
||||
37 | * @return RouteCollection|Route[] |
||||
38 | */ |
||||
39 | 1 | public function getRoutes() |
|||
40 | { |
||||
41 | 1 | return $this->getRouteCollection(); |
|||
42 | } |
||||
43 | |||||
44 | /** |
||||
45 | * @param Route $route |
||||
46 | */ |
||||
47 | 1 | public function addRoute($route) |
|||
48 | { |
||||
49 | 1 | $this->getRouteCollection()->addRoute($route); |
|||
50 | 1 | } |
|||
51 | |||||
52 | /** |
||||
53 | * @param $name |
||||
54 | * @return bool |
||||
55 | */ |
||||
56 | public function connected($name) |
||||
57 | { |
||||
58 | return $this->hasRoute($name); |
||||
59 | } |
||||
60 | |||||
61 | /** |
||||
62 | * @param string $name |
||||
63 | * @return bool |
||||
64 | */ |
||||
65 | public function hasRoute($name) |
||||
66 | { |
||||
67 | return $this->getGenerator()->hasRoute($name); |
||||
0 ignored issues
–
show
It seems like
getGenerator() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
68 | } |
||||
69 | |||||
70 | 6 | public function initRouteCollection() |
|||
71 | { |
||||
72 | 6 | $this->collection = $this->newRoutesCollection(); |
|||
0 ignored issues
–
show
|
|||||
73 | 6 | } |
|||
74 | |||||
75 | /** |
||||
76 | * @return RouteCollection |
||||
77 | */ |
||||
78 | 6 | protected function newRoutesCollection() |
|||
79 | { |
||||
80 | 6 | return new RouteCollection(); |
|||
81 | } |
||||
82 | } |
||||
83 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths