This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Consolidation\SiteAlias; |
||
3 | |||
4 | use Consolidation\Config\Config; |
||
5 | use Consolidation\Config\ConfigInterface; |
||
6 | use Consolidation\Config\Util\ArrayUtil; |
||
7 | use Consolidation\SiteAlias\Util\FsUtils; |
||
8 | |||
9 | /** |
||
10 | * Common implementation of some SiteAlias methods. |
||
11 | */ |
||
12 | trait SiteAliasTrait |
||
13 | { |
||
14 | /** |
||
15 | * @inheritdoc |
||
16 | */ |
||
17 | public function hasRoot() |
||
18 | { |
||
19 | return $this->has('root'); |
||
0 ignored issues
–
show
|
|||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @inheritdoc |
||
24 | * |
||
25 | * @throws \Exception when the alias does not specify a root. |
||
26 | */ |
||
27 | public function root() |
||
28 | { |
||
29 | if (!$this->hasRoot()) { |
||
30 | throw new \Exception('Site alias ' . $this->name . ' does not specify a root.'); |
||
0 ignored issues
–
show
The property
name does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
31 | } |
||
32 | $root = $this->get('root'); |
||
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
33 | if ($this->isLocal()) { |
||
34 | return FsUtils::realpath($root); |
||
35 | } |
||
36 | return $root; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @inheritdoc |
||
41 | */ |
||
42 | public function uri() |
||
43 | { |
||
44 | return $this->get('uri'); |
||
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | */ |
||
50 | public function setUri($uri) |
||
51 | { |
||
52 | return $this->set('uri', $uri); |
||
0 ignored issues
–
show
It seems like
set() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | public function remoteHostWithUser() |
||
59 | { |
||
60 | $result = $this->remoteHost(); |
||
61 | if (!empty($result) && $this->hasRemoteUser()) { |
||
62 | $result = $this->remoteUser() . '@' . $result; |
||
63 | } |
||
64 | return $result; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @inheritdoc |
||
69 | */ |
||
70 | public function remoteUser() |
||
71 | { |
||
72 | return $this->get('user'); |
||
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @inheritdoc |
||
77 | */ |
||
78 | public function hasRemoteUser() |
||
79 | { |
||
80 | return $this->has('user'); |
||
0 ignored issues
–
show
It seems like
has() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @inheritdoc |
||
85 | */ |
||
86 | public function remoteHost() |
||
87 | { |
||
88 | return $this->get('host'); |
||
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | public function isRemote() |
||
95 | { |
||
96 | return $this->has('host'); |
||
0 ignored issues
–
show
It seems like
has() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | public function isLocal() |
||
103 | { |
||
104 | return !$this->isRemote() && !$this->isContainer(); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | public function isContainer() |
||
111 | { |
||
112 | return $this->has('docker'); |
||
0 ignored issues
–
show
It seems like
has() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
113 | } |
||
114 | |||
115 | /** |
||
116 | * @inheritdoc |
||
117 | */ |
||
118 | public function isNone() |
||
119 | { |
||
120 | return empty($this->root()) && $this->isLocal(); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @inheritdoc |
||
125 | */ |
||
126 | public function localRoot() |
||
127 | { |
||
128 | if ($this->isLocal() && $this->hasRoot()) { |
||
129 | return $this->root(); |
||
130 | } |
||
131 | |||
132 | return false; |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * os returns the OS that this alias record points to. For local alias |
||
137 | * records, PHP_OS will be returned. For remote alias records, the |
||
138 | * value from the `os` element will be returned. If there is no `os` |
||
139 | * element, then the default assumption is that the remote system is Linux. |
||
140 | * |
||
141 | * @return string |
||
142 | * Linux |
||
143 | * WIN* (e.g. WINNT) |
||
144 | * CYGWIN |
||
145 | * MINGW* (e.g. MINGW32) |
||
146 | */ |
||
147 | public function os() |
||
148 | { |
||
149 | if ($this->isLocal()) { |
||
150 | return PHP_OS; |
||
151 | } |
||
152 | return $this->get('os', 'Linux'); |
||
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
153 | } |
||
154 | } |
||
155 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.