Skip to content

Commit

Permalink
Make idnSupported() static (PHPMailer#1203)
Browse files Browse the repository at this point in the history
Upgrade guide and changelog say that idnSupported() is now static, but it actually isn't.

Probably this PR should wait v6.1 or other version where breaking changes are OK.
  • Loading branch information
fbonzon authored and Synchro committed Oct 14, 2017
1 parent 916d68c commit 10341cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/PHPMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ protected function addOrEnqueueAnAddress($kind, $address, $name)
}
$params = [$kind, $address, $name];
// Enqueue addresses with IDN until we know the PHPMailer::$CharSet.
if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) {
if ($this->has8bitChars(substr($address, ++$pos)) and static::idnSupported()) {
if ('Reply-To' != $kind) {
if (!array_key_exists($address, $this->RecipientsQueue)) {
$this->RecipientsQueue[$address] = $params;
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public function setFrom($address, $name = '', $auto = true)
// Don't validate now addresses with IDN. Will be done in send().
$pos = strrpos($address, '@');
if (false === $pos or
(!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and
(!$this->has8bitChars(substr($address, ++$pos)) or !static::idnSupported()) and
!static::validateAddress($address)) {
$error_message = $this->lang('invalid_address') . " (setFrom) $address";
$this->setError($error_message);
Expand Down Expand Up @@ -1249,7 +1249,7 @@ public static function validateAddress($address, $patternselect = null)
*
* @return bool `true` if required functions for IDN support are present
*/
public function idnSupported()
public static function idnSupported()
{
return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding');
}
Expand All @@ -1272,7 +1272,7 @@ public function punyencodeAddress($address)
{
// Verify we have required functions, CharSet, and at-sign.
$pos = strrpos($address, '@');
if ($this->idnSupported() and
if (static::idnSupported() and
!empty($this->CharSet) and
false !== $pos
) {
Expand Down
6 changes: 3 additions & 3 deletions test/PHPMailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,7 @@ public function testConfirmReadingTo()
);

$this->Mail->ConfirmReadingTo = 'test@françois.ch'; //Address with IDN
if ($this->Mail->idnSupported()) {
if (PHPMailer::idnSupported()) {
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
$this->assertEquals(
'test@xn--franois-xxa.ch',
Expand All @@ -2209,7 +2209,7 @@ public function testConfirmReadingTo()
*/
public function testConvertEncoding()
{
if (!$this->Mail->idnSupported()) {
if (!PHPMailer::idnSupported()) {
$this->markTestSkipped('intl and/or mbstring extensions are not available');
}

Expand Down Expand Up @@ -2260,7 +2260,7 @@ public function testConvertEncoding()
*/
public function testDuplicateIDNRemoved()
{
if (!$this->Mail->idnSupported()) {
if (!PHPMailer::idnSupported()) {
$this->markTestSkipped('intl and/or mbstring extensions are not available');
}

Expand Down

0 comments on commit 10341cc

Please sign in to comment.