1 | <?php |
||
10 | class MixedContentObserver extends CrawlObserver |
||
11 | { |
||
12 | private $crawledCss = []; |
||
13 | |||
14 | private $shouldExtractLinkedCss = false; |
||
15 | |||
16 | public function crawled(UriInterface $url, ResponseInterface $response, ?UriInterface $foundOnUrl = null) |
||
36 | |||
37 | public function crawlFailed( |
||
43 | |||
44 | /** |
||
45 | * Will be called when mixed content was found. |
||
46 | * |
||
47 | * @param \Spatie\MixedContentScanner\MixedContent $mixedContent |
||
48 | */ |
||
49 | public function mixedContentFound(MixedContent $mixedContent) |
||
52 | |||
53 | /** |
||
54 | * Will be called when no mixed content was found on the given url. |
||
55 | * |
||
56 | * @param \Psr\Http\Message\UriInterface |
||
57 | */ |
||
58 | public function noMixedContentFound(UriInterface $crawledUrl) |
||
61 | |||
62 | public function getMixedContentFromLinkedCss(UriInterface $css, UriInterface $linkedByUrl) |
||
76 | |||
77 | public function withLinkedCss() |
||
83 | } |
||
84 |
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
The above code is perfectly fine. Now imagine that we re-order the statements:
In that case,
$x
would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.