cast substr result to string and remove empty function use

This commit is contained in:
apetitpa 2017-03-24 23:09:52 +01:00 committed by Fabien Potencier
parent 894127bf09
commit 1825d0f2ae

View File

@ -93,7 +93,7 @@ class EmailValidator extends ConstraintValidator
return; return;
} }
$host = substr($value, strrpos($value, '@') + 1); $host = (string) substr($value, strrpos($value, '@') + 1);
// Check for host DNS resource records // Check for host DNS resource records
if ($constraint->checkMX) { if ($constraint->checkMX) {
@ -138,7 +138,7 @@ class EmailValidator extends ConstraintValidator
*/ */
private function checkMX($host) private function checkMX($host)
{ {
return !empty($host) && checkdnsrr($host, 'MX'); return '' !== $host && checkdnsrr($host, 'MX');
} }
/** /**
@ -150,6 +150,6 @@ class EmailValidator extends ConstraintValidator
*/ */
private function checkHost($host) private function checkHost($host)
{ {
return !empty($host) && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'))); return '' !== $host && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')));
} }
} }