1 | <?php |
||
29 | class IspDb { |
||
30 | |||
31 | /** @var Logger */ |
||
32 | private $logger; |
||
33 | |||
34 | /** @var string[] */ |
||
35 | 2 | public function getUrls() { |
|
42 | |||
43 | /** |
||
44 | * @param Logger $logger |
||
45 | * @param string[] $ispUrls |
||
|
|||
46 | */ |
||
47 | 3 | public function __construct(Logger $logger) { |
|
50 | |||
51 | 3 | private function queryUrl($url) { |
|
52 | try { |
||
53 | 3 | $content = @file_get_contents($url, false, stream_context_create([ |
|
54 | 'http' => [ |
||
55 | 'timeout' => 7 |
||
56 | 3 | ] |
|
57 | 3 | ])); |
|
58 | 3 | if ($content !== false) { |
|
59 | 3 | $xml = @simplexml_load_string($content); |
|
60 | 3 | } else { |
|
61 | 2 | $this->logger->debug("IsbDb: <$url> request timed out"); |
|
62 | 2 | return []; |
|
63 | } |
||
64 | |||
65 | 3 | if (libxml_get_last_error() !== false || !is_object($xml) || !$xml->emailProvider) { |
|
66 | libxml_clear_errors(); |
||
67 | return []; |
||
68 | } |
||
69 | $provider = [ |
||
70 | 3 | 'displayName' => (string) $xml->emailProvider->displayName, |
|
71 | 3 | ]; |
|
72 | 3 | foreach ($xml->emailProvider->children() as $tag => $server) { |
|
73 | 3 | if (!in_array($tag, ['incomingServer', 'outgoingServer'])) { |
|
74 | 3 | continue; |
|
75 | } |
||
76 | 3 | foreach ($server->attributes() as $name => $value) { |
|
77 | 3 | if ($name == 'type') { |
|
78 | 3 | $type = (string) $value; |
|
79 | 3 | } |
|
80 | 3 | } |
|
81 | 3 | $data = []; |
|
82 | 3 | foreach ($server as $name => $value) { |
|
83 | 3 | foreach ($value->children() as $tag => $val) { |
|
84 | 2 | $data[$name][$tag] = (string) $val; |
|
85 | 3 | } |
|
86 | 3 | if (!isset($data[$name])) { |
|
87 | 3 | $data[$name] = (string) $value; |
|
88 | 3 | } |
|
89 | 3 | } |
|
90 | 3 | $provider[$type][] = $data; |
|
91 | 3 | } |
|
92 | 3 | } catch (Exception $e) { |
|
93 | // ignore own not-found exception or xml parsing exceptions |
||
94 | unset($e); |
||
95 | $provider = []; |
||
96 | } |
||
97 | 3 | return $provider; |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param string $domain |
||
102 | * @return array |
||
103 | */ |
||
104 | 3 | public function query($domain, $tryMx = true) { |
|
131 | |||
132 | } |
||
133 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.