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 | |||
3 | namespace Facade\FlareClient; |
||
4 | |||
5 | use Facade\FlareClient\Concerns\HasContext; |
||
6 | use Facade\FlareClient\Concerns\UsesTime; |
||
7 | use Facade\FlareClient\Context\ContextInterface; |
||
8 | use Facade\FlareClient\Contracts\ProvidesFlareContext; |
||
9 | use Facade\FlareClient\Enums\GroupingTypes; |
||
10 | use Facade\FlareClient\Glows\Glow; |
||
11 | use Facade\FlareClient\Solutions\ReportSolution; |
||
12 | use Facade\FlareClient\Stacktrace\Stacktrace; |
||
13 | use Facade\Ignition\Exceptions\ViewException; |
||
14 | use Facade\IgnitionContracts\Solution; |
||
15 | use Throwable; |
||
16 | |||
17 | class Report |
||
18 | { |
||
19 | use UsesTime, HasContext; |
||
20 | |||
21 | /** @var \Facade\FlareClient\Stacktrace\Stacktrace */ |
||
22 | private $stacktrace; |
||
23 | |||
24 | /** @var string */ |
||
25 | private $exceptionClass; |
||
26 | |||
27 | /** @var string */ |
||
28 | private $message; |
||
29 | |||
30 | /** @var array */ |
||
31 | private $glows = []; |
||
32 | |||
33 | /** @var array */ |
||
34 | private $solutions = []; |
||
35 | |||
36 | /** @var ContextInterface */ |
||
37 | private $context; |
||
38 | |||
39 | /** @var string */ |
||
40 | private $applicationPath; |
||
41 | |||
42 | /** @var array */ |
||
43 | private $userProvidedContext = []; |
||
44 | |||
45 | /** @var array */ |
||
46 | private $exceptionContext = []; |
||
47 | |||
48 | /** @var Throwable */ |
||
49 | private $throwable; |
||
50 | |||
51 | /** @var string */ |
||
52 | private $notifierName; |
||
53 | |||
54 | /** @var string */ |
||
55 | private $languageVersion; |
||
56 | |||
57 | /** @var string */ |
||
58 | private $frameworkVersion; |
||
59 | |||
60 | /** @var int */ |
||
61 | private $openFrameIndex; |
||
62 | |||
63 | /** @var string */ |
||
64 | private $groupBy; |
||
65 | |||
66 | public static function createForThrowable(Throwable $throwable, ContextInterface $context, ?string $applicationPath = null): self |
||
67 | { |
||
68 | return (new static()) |
||
69 | ->setApplicationPath($applicationPath) |
||
70 | ->throwable($throwable) |
||
71 | ->useContext($context) |
||
72 | ->exceptionClass(self::getClassForThrowable($throwable)) |
||
73 | ->message($throwable->getMessage()) |
||
74 | ->stackTrace(Stacktrace::createForThrowable($throwable, $applicationPath)) |
||
75 | ->exceptionContext($throwable); |
||
76 | } |
||
77 | |||
78 | protected static function getClassForThrowable(Throwable $throwable): string |
||
79 | { |
||
80 | if ($throwable instanceof \Facade\Ignition\Exceptions\ViewException) { |
||
0 ignored issues
–
show
|
|||
81 | if ($previous = $throwable->getPrevious()) |
||
82 | return get_class($previous); |
||
83 | } |
||
84 | |||
85 | return get_class($throwable); |
||
86 | } |
||
87 | |||
88 | public static function createForMessage(string $message, string $logLevel, ContextInterface $context, ?string $applicationPath = null): self |
||
89 | { |
||
90 | $stacktrace = Stacktrace::create($applicationPath); |
||
91 | |||
92 | return (new static()) |
||
93 | ->setApplicationPath($applicationPath) |
||
94 | ->message($message) |
||
95 | ->useContext($context) |
||
96 | ->exceptionClass($logLevel) |
||
97 | ->stacktrace($stacktrace) |
||
98 | ->openFrameIndex($stacktrace->firstApplicationFrameIndex()); |
||
99 | } |
||
100 | |||
101 | public function exceptionClass(string $exceptionClass) |
||
102 | { |
||
103 | $this->exceptionClass = $exceptionClass; |
||
104 | |||
105 | return $this; |
||
106 | } |
||
107 | |||
108 | public function getExceptionClass(): string |
||
109 | { |
||
110 | return $this->exceptionClass; |
||
111 | } |
||
112 | |||
113 | public function throwable(Throwable $throwable) |
||
114 | { |
||
115 | $this->throwable = $throwable; |
||
116 | |||
117 | return $this; |
||
118 | } |
||
119 | |||
120 | public function getThrowable(): ?Throwable |
||
121 | { |
||
122 | return $this->throwable; |
||
123 | } |
||
124 | |||
125 | public function message(string $message) |
||
126 | { |
||
127 | $this->message = $message; |
||
128 | |||
129 | return $this; |
||
130 | } |
||
131 | |||
132 | public function getMessage(): string |
||
133 | { |
||
134 | return $this->message; |
||
135 | } |
||
136 | |||
137 | public function stacktrace(Stacktrace $stacktrace) |
||
138 | { |
||
139 | $this->stacktrace = $stacktrace; |
||
140 | |||
141 | return $this; |
||
142 | } |
||
143 | |||
144 | public function getStacktrace(): Stacktrace |
||
145 | { |
||
146 | return $this->stacktrace; |
||
147 | } |
||
148 | |||
149 | public function notifierName(string $notifierName) |
||
150 | { |
||
151 | $this->notifierName = $notifierName; |
||
152 | |||
153 | return $this; |
||
154 | } |
||
155 | |||
156 | public function languageVersion(string $languageVersion) |
||
157 | { |
||
158 | $this->languageVersion = $languageVersion; |
||
159 | |||
160 | return $this; |
||
161 | } |
||
162 | |||
163 | public function frameworkVersion(string $frameworkVersion) |
||
164 | { |
||
165 | $this->frameworkVersion = $frameworkVersion; |
||
166 | |||
167 | return $this; |
||
168 | } |
||
169 | |||
170 | public function useContext(ContextInterface $request) |
||
171 | { |
||
172 | $this->context = $request; |
||
173 | |||
174 | return $this; |
||
175 | } |
||
176 | |||
177 | public function openFrameIndex(?int $index) |
||
178 | { |
||
179 | $this->openFrameIndex = $index; |
||
180 | |||
181 | return $this; |
||
182 | } |
||
183 | |||
184 | public function setApplicationPath(?string $applicationPath) |
||
185 | { |
||
186 | $this->applicationPath = $applicationPath; |
||
187 | |||
188 | return $this; |
||
189 | } |
||
190 | |||
191 | public function getApplicationPath(): ?string |
||
192 | { |
||
193 | return $this->applicationPath; |
||
194 | } |
||
195 | |||
196 | public function view(?View $view) |
||
197 | { |
||
198 | $this->view = $view; |
||
0 ignored issues
–
show
The property
view 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;
![]() |
|||
199 | |||
200 | return $this; |
||
201 | } |
||
202 | |||
203 | public function addGlow(Glow $glow) |
||
204 | { |
||
205 | $this->glows[] = $glow->toArray(); |
||
206 | |||
207 | return $this; |
||
208 | } |
||
209 | |||
210 | public function addSolution(Solution $solution) |
||
211 | { |
||
212 | $this->solutions[] = ReportSolution::fromSolution($solution)->toArray(); |
||
213 | |||
214 | return $this; |
||
215 | } |
||
216 | |||
217 | public function userProvidedContext(array $userProvidedContext) |
||
218 | { |
||
219 | $this->userProvidedContext = $userProvidedContext; |
||
220 | |||
221 | return $this; |
||
222 | } |
||
223 | |||
224 | public function groupByTopFrame() |
||
225 | { |
||
226 | $this->groupBy = GroupingTypes::TOP_FRAME; |
||
227 | |||
228 | return $this; |
||
229 | } |
||
230 | |||
231 | public function groupByException() |
||
232 | { |
||
233 | $this->groupBy = GroupingTypes::EXCEPTION; |
||
234 | |||
235 | return $this; |
||
236 | } |
||
237 | |||
238 | public function allContext(): array |
||
239 | { |
||
240 | $context = $this->context->toArray(); |
||
241 | |||
242 | $context = array_merge_recursive_distinct($context, $this->exceptionContext); |
||
243 | |||
244 | return array_merge_recursive_distinct($context, $this->userProvidedContext); |
||
245 | } |
||
246 | |||
247 | private function exceptionContext(Throwable $throwable) |
||
248 | { |
||
249 | if ($throwable instanceof ProvidesFlareContext) { |
||
250 | $this->exceptionContext = $throwable->context(); |
||
251 | } |
||
252 | |||
253 | return $this; |
||
254 | } |
||
255 | |||
256 | public function toArray() |
||
257 | { |
||
258 | return [ |
||
259 | 'notifier' => $this->notifierName ?? 'Flare Client', |
||
260 | 'language' => 'PHP', |
||
261 | 'framework_version' => $this->frameworkVersion, |
||
262 | 'language_version' => $this->languageVersion ?? phpversion(), |
||
263 | 'exception_class' => $this->exceptionClass, |
||
264 | 'seen_at' => $this->getCurrentTime(), |
||
265 | 'message' => $this->message, |
||
266 | 'glows' => $this->glows, |
||
267 | 'solutions' => $this->solutions, |
||
268 | 'stacktrace' => $this->stacktrace->toArray(), |
||
269 | 'context' => $this->allContext(), |
||
270 | 'stage' => $this->stage, |
||
271 | 'message_level' => $this->messageLevel, |
||
272 | 'open_frame_index' => $this->openFrameIndex, |
||
273 | 'group_by' => $this->groupBy ?? GroupingTypes::TOP_FRAME, |
||
274 | 'application_path' => $this->applicationPath, |
||
275 | ]; |
||
276 | } |
||
277 | } |
||
278 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.