Unverified Commit f849b0ab authored by Sam Williams's avatar Sam Williams Committed by GitHub
Browse files

Merge pull request #44 from Livda/fix-return-types

better types attributes and return types
parents ef84e289 c17a5775
......@@ -21,7 +21,7 @@ class A implements RdataInterface
const TYPE = 'A';
/**
* @var string
* @var string|null
*/
protected $address;
......@@ -36,7 +36,7 @@ class A implements RdataInterface
/**
* @return string
*/
public function getAddress(): string
public function getAddress(): ?string
{
return $this->address;
}
......@@ -46,6 +46,6 @@ class A implements RdataInterface
*/
public function output(): string
{
return $this->address;
return $this->address ?? '';
}
}
......@@ -39,7 +39,7 @@ class CAA implements RdataInterface
/**
* It is currently used to represent the critical flag.
*
* @var int
* @var int|null
*/
private $flag;
......@@ -50,12 +50,12 @@ class CAA implements RdataInterface
* - issuewild: explicity authorizes a single certificate authority to issue a wildcard certificate (and only wildcard) for the hostname.
* - iodef: specifies a URL to which a certificate authority may report policy violations.
*
* @var string
* @var string|null
*/
private $tag;
/**
* @var string
* @var string|null
*/
private $value;
......@@ -104,9 +104,9 @@ class CAA implements RdataInterface
}
/**
* @return string
* @return string|null
*/
public function getValue(): string
public function getValue(): ?string
{
return $this->value;
}
......@@ -126,8 +126,8 @@ class CAA implements RdataInterface
{
return sprintf('%d %s "%s"',
$this->flag,
$this->tag,
$this->value
$this->tag ?? '',
$this->value ?? ''
);
}
}
......@@ -21,7 +21,7 @@ class CNAME implements RdataInterface
const TYPE = 'CNAME';
/**
* @var string
* @var string|null
*/
protected $target;
......@@ -46,6 +46,6 @@ class CNAME implements RdataInterface
*/
public function output(): string
{
return $this->target;
return $this->target ?? '';
}
}
......@@ -21,12 +21,12 @@ class HINFO implements RdataInterface
const TYPE = 'HINFO';
/**
* @var string
* @var string|null
*/
private $cpu;
/**
* @var string
* @var string|null
*/
private $os;
......@@ -67,6 +67,6 @@ class HINFO implements RdataInterface
*/
public function output(): string
{
return sprintf('"%s" "%s"', $this->cpu, $this->os);
return sprintf('"%s" "%s"', $this->cpu ?? '', $this->os ?? '');
}
}
......@@ -34,12 +34,12 @@ class LOC implements RdataInterface
const FORMAT_DMS = 'DMS';
/**
* @var float
* @var float|null
*/
private $latitude;
/**
* @var float
* @var float|null
*/
private $longitude;
......@@ -79,7 +79,7 @@ class LOC implements RdataInterface
public function getLatitude(string $format = self::FORMAT_DECIMAL)
{
if (self::FORMAT_DMS === $format) {
return $this->toDms($this->latitude, self::LATITUDE);
return $this->toDms($this->latitude ?? 0, self::LATITUDE);
}
return $this->latitude;
......@@ -101,7 +101,7 @@ class LOC implements RdataInterface
public function getLongitude(string $format = self::FORMAT_DECIMAL)
{
if (self::FORMAT_DMS === $format) {
return $this->toDms($this->longitude, self::LONGITUDE);
return $this->toDms($this->longitude ?? 0, self::LONGITUDE);
}
return $this->longitude;
......
......@@ -21,12 +21,12 @@ class MX implements RdataInterface
const TYPE = 'MX';
/**
* @var int
* @var int|null
*/
private $preference;
/**
* @var string
* @var string|null
*/
private $exchange;
......@@ -39,7 +39,7 @@ class MX implements RdataInterface
}
/**
* @return string
* @return string|null
*/
public function getExchange(): ?string
{
......@@ -55,7 +55,7 @@ class MX implements RdataInterface
}
/**
* @return int
* @return int|null
*/
public function getPreference(): ?int
{
......
......@@ -19,12 +19,12 @@ class PolymorphicRdata implements RdataInterface
/**
* The RData type.
*
* @var string
* @var string|null
*/
private $type;
/**
* @var string
* @var string|null
*/
private $data;
......@@ -58,7 +58,7 @@ class PolymorphicRdata implements RdataInterface
*/
public function getType(): string
{
return $this->type;
return $this->type ?? '';
}
/**
......@@ -70,9 +70,9 @@ class PolymorphicRdata implements RdataInterface
}
/**
* @return string
* @return string|null
*/
public function getData(): string
public function getData(): ?string
{
return $this->data;
}
......@@ -82,6 +82,6 @@ class PolymorphicRdata implements RdataInterface
*/
public function output(): string
{
return $this->getData();
return $this->getData() ?? '';
}
}
......@@ -24,7 +24,7 @@ class SOA implements RdataInterface
* The <domain-name> of the name server that was the
* original or primary source of data for this zone.
*
* @var string
* @var string|null
*/
private $mname;
......@@ -32,7 +32,7 @@ class SOA implements RdataInterface
* A <domain-name> which specifies the mailbox of the
* person responsible for this zone.
*
* @var string
* @var string|null
*/
private $rname;
......@@ -40,7 +40,7 @@ class SOA implements RdataInterface
* The unsigned 32 bit version number of the original copy
* of the zone.
*
* @var int
* @var int|null
*/
private $serial;
......@@ -48,7 +48,7 @@ class SOA implements RdataInterface
* A 32 bit time interval before the zone should be
* refreshed.
*
* @var int
* @var int|null
*/
private $refresh;
......@@ -56,7 +56,7 @@ class SOA implements RdataInterface
* A 32 bit time interval that should elapse before a
* failed refresh should be retried.
*
* @var int
* @var int|null
*/
private $retry;
......@@ -65,7 +65,7 @@ class SOA implements RdataInterface
* the time interval that can elapse before the zone is no
* longer authoritative.
*
* @var int
* @var int|null
*/
private $expire;
......@@ -73,7 +73,7 @@ class SOA implements RdataInterface
* The unsigned 32 bit minimum TTL field that should be
* exported with any RR from this zone.
*
* @var int
* @var int|null
*/
private $minimum;
......
......@@ -37,7 +37,7 @@ class SRV extends CNAME
* order defined by the weight field. The range is 0-65535. This
* is a 16 bit unsigned integer.
*
* @var int
* @var int|null
*/
private $priority;
......@@ -46,7 +46,7 @@ class SRV extends CNAME
* relative weight for entries with the same priority. The range
* is 0-65535. This is a 16 bit unsigned integer.
*
* @var int
* @var int|null
*/
private $weight;
......@@ -54,7 +54,7 @@ class SRV extends CNAME
* The port on this target host of this service. The range is
* 0-65535. This is a 16 bit unsigned integer.
*
* @var int
* @var int|null
*/
private $port;
......
......@@ -155,6 +155,6 @@ class ZoneBuilder
*/
protected static function fillOutAaaa(AAAA $rdata, Zone $zone): void
{
$rdata->setAddress(Toolbox::expandIpv6($rdata->getAddress()));
$rdata->setAddress(Toolbox::expandIpv6($rdata->getAddress() ?? ''));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment