Completed
Push — master ( 756614...79788d )
by Johnny
02:09
created

src/Resolver.php (3 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redbox\DNS;
3
4
class Resolver extends Reflectable
5
{
6
    /**
7
     * Resolver constructor.
8
     */
9 16
    public function __construct()
10
    {
11 16
        $this->ADITIONAL = [];
0 ignored issues
show
The property ADITIONAL does not exist on object<Redbox\DNS\Resolver>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
12 16
        $this->DNS       = [];
0 ignored issues
show
The property DNS does not exist on object<Redbox\DNS\Resolver>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
13 16
        $this->NS        = [];
0 ignored issues
show
The property NS does not exist on object<Redbox\DNS\Resolver>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
14 16
    }
15
16
    /**
17
     * @param string $domain
18
     * @param int $type
19
     * @return bool
20
     */
21 16
    public function resolve($domain = '', $type = DNS_ANY)
22
    {
23 16
        if (empty($domain))
24 16
            return false;
25
26 12
        $this->clear();
27
28 12
        $result = dns_get_record($domain, $type, $authns, $addtl);
29
30 12
        if (empty($result) || $result === false) {
31 4
            return false;
32
        }
33
34
        list(
35 8
            $this->DNS,
36 8
            $this->NS,
37 8
            $this->ADITIONAL
38 8
            ) = [$result, $authns, $addtl];
39
40 8
        return true;
41
    }
42
43
}