These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace PHPHtmlParser; |
||
3 | |||
4 | use PHPHtmlParser\Exceptions\NotLoadedException; |
||
5 | |||
6 | /** |
||
7 | * Class StaticDom |
||
8 | * |
||
9 | * @package PHPHtmlParser |
||
10 | */ |
||
11 | final class StaticDom |
||
12 | { |
||
13 | |||
14 | private static $dom = null; |
||
15 | |||
16 | /** |
||
17 | * Attempts to call the given method on the most recent created dom |
||
18 | * from bellow. |
||
19 | * |
||
20 | * @param string $method |
||
21 | * @param array $arguments |
||
22 | * @throws NotLoadedException |
||
23 | * @return mixed |
||
24 | */ |
||
25 | public static function __callStatic($method, $arguments) |
||
26 | { |
||
27 | if (self::$dom instanceof Dom) { |
||
28 | return call_user_func_array([self::$dom, $method], $arguments); |
||
29 | } else { |
||
30 | throw new NotLoadedException('The dom is not loaded. Can not call a dom method.'); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Call this to mount the static facade. The facade allows you to use |
||
36 | * this object as a $className. |
||
37 | * |
||
38 | * @param string $className |
||
39 | * @param Dom $dom |
||
40 | * @return bool |
||
41 | */ |
||
42 | public static function mount($className = 'Dom', Dom $dom = null) |
||
43 | { |
||
44 | if (class_exists($className)) { |
||
45 | return false; |
||
46 | } |
||
47 | class_alias(__CLASS__, $className); |
||
48 | if ($dom instanceof Dom) { |
||
49 | self::$dom = $dom; |
||
50 | } |
||
51 | |||
52 | return true; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Creates a new dom object and calls load() on the |
||
57 | * new object. |
||
58 | * |
||
59 | * @param string $str |
||
60 | * @return $this |
||
61 | */ |
||
62 | public static function load($str) |
||
63 | { |
||
64 | $dom = new Dom; |
||
65 | self::$dom = $dom; |
||
66 | |||
67 | return $dom->load($str); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Creates a new dom object and calls loadFromFile() on the |
||
72 | * new object. |
||
73 | * |
||
74 | * @param string $file |
||
75 | * @return $this |
||
76 | */ |
||
77 | public static function loadFromFile($file) |
||
78 | { |
||
79 | $dom = new Dom; |
||
80 | self::$dom = $dom; |
||
81 | |||
82 | return $dom->loadFromFile($file); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Creates a new dom object and calls loadFromUrl() on the |
||
87 | * new object. |
||
88 | * |
||
89 | * @param string $url |
||
90 | * @param CurlInterface $curl |
||
91 | * @return $this |
||
92 | */ |
||
93 | public static function loadFromUrl($url, CurlInterface $curl = null) |
||
94 | { |
||
95 | $dom = new Dom; |
||
96 | self::$dom = $dom; |
||
97 | if (is_null($curl)) { |
||
98 | // use the default curl interface |
||
99 | $curl = new Curl; |
||
100 | } |
||
101 | |||
102 | return $dom->loadFromUrl($url, $curl); |
||
0 ignored issues
–
show
|
|||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Sets the $dom variable to null. |
||
107 | */ |
||
108 | public static function unload() |
||
109 | { |
||
110 | self::$dom = null; |
||
111 | } |
||
112 | } |
||
113 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: