2
0
forked from Wavyzz/dolibarr

swiftmailer

This commit is contained in:
Frédéric FRANCE
2018-01-21 15:55:56 +01:00
parent 3a8ceb130f
commit a34b99f3ec
191 changed files with 5164 additions and 4074 deletions

View File

@@ -20,28 +20,28 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
*
* @var int
*/
private $_threshold;
private $threshold;
/**
* The number of seconds to sleep for during a restart.
*
* @var int
*/
private $_sleep;
private $sleep;
/**
* The internal counter.
*
* @var int
*/
private $_counter = 0;
private $counter = 0;
/**
* The Sleeper instance for sleeping.
*
* @var Swift_Plugins_Sleeper
*/
private $_sleeper;
private $sleeper;
/**
* Create a new AntiFloodPlugin with $threshold and $sleep time.
@@ -54,7 +54,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
{
$this->setThreshold($threshold);
$this->setSleepTime($sleep);
$this->_sleeper = $sleeper;
$this->sleeper = $sleeper;
}
/**
@@ -64,7 +64,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
*/
public function setThreshold($threshold)
{
$this->_threshold = $threshold;
$this->threshold = $threshold;
}
/**
@@ -74,7 +74,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
*/
public function getThreshold()
{
return $this->_threshold;
return $this->threshold;
}
/**
@@ -84,7 +84,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
*/
public function setSleepTime($sleep)
{
$this->_sleep = $sleep;
$this->sleep = $sleep;
}
/**
@@ -94,7 +94,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
*/
public function getSleepTime()
{
return $this->_sleep;
return $this->sleep;
}
/**
@@ -113,15 +113,15 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
{
++$this->_counter;
if ($this->_counter >= $this->_threshold) {
++$this->counter;
if ($this->counter >= $this->threshold) {
$transport = $evt->getTransport();
$transport->stop();
if ($this->_sleep) {
$this->sleep($this->_sleep);
if ($this->sleep) {
$this->sleep($this->sleep);
}
$transport->start();
$this->_counter = 0;
$this->counter = 0;
}
}
@@ -132,8 +132,8 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
*/
public function sleep($seconds)
{
if (isset($this->_sleeper)) {
$this->_sleeper->sleep($seconds);
if (isset($this->sleeper)) {
$this->sleeper->sleep($seconds);
} else {
sleep($seconds);
}

View File

@@ -20,17 +20,17 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*
* @var int
*/
private $_out = 0;
private $out = 0;
/**
* The incoming traffic counter.
*
* @var int
*/
private $_in = 0;
private $in = 0;
/** Bound byte streams */
private $_mirrors = array();
private $mirrors = array();
/**
* Not used.
@@ -58,7 +58,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
public function commandSent(Swift_Events_CommandEvent $evt)
{
$command = $evt->getCommand();
$this->_out += strlen($command);
$this->out += strlen($command);
}
/**
@@ -69,7 +69,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
public function responseReceived(Swift_Events_ResponseEvent $evt)
{
$response = $evt->getResponse();
$this->_in += strlen($response);
$this->in += strlen($response);
}
/**
@@ -79,8 +79,8 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*/
public function write($bytes)
{
$this->_out += strlen($bytes);
foreach ($this->_mirrors as $stream) {
$this->out += strlen($bytes);
foreach ($this->mirrors as $stream) {
$stream->write($bytes);
}
}
@@ -102,7 +102,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*/
public function bind(Swift_InputByteStream $is)
{
$this->_mirrors[] = $is;
$this->mirrors[] = $is;
}
/**
@@ -116,9 +116,9 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*/
public function unbind(Swift_InputByteStream $is)
{
foreach ($this->_mirrors as $k => $stream) {
foreach ($this->mirrors as $k => $stream) {
if ($is === $stream) {
unset($this->_mirrors[$k]);
unset($this->mirrors[$k]);
}
}
}
@@ -128,7 +128,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*/
public function flushBuffers()
{
foreach ($this->_mirrors as $stream) {
foreach ($this->mirrors as $stream) {
$stream->flushBuffers();
}
}
@@ -140,7 +140,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*/
public function getBytesOut()
{
return $this->_out;
return $this->out;
}
/**
@@ -150,7 +150,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*/
public function getBytesIn()
{
return $this->_in;
return $this->in;
}
/**
@@ -158,7 +158,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
*/
public function reset()
{
$this->_out = 0;
$this->_in = 0;
$this->out = 0;
$this->in = 0;
}
}

View File

@@ -17,19 +17,19 @@
class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements
{
/** The replacement map */
private $_replacements;
private $replacements;
/** The body as it was before replacements */
private $_originalBody;
private $originalBody;
/** The original headers of the message, before replacements */
private $_originalHeaders = array();
private $originalHeaders = array();
/** Bodies of children before they are replaced */
private $_originalChildBodies = array();
private $originalChildBodies = array();
/** The Message that was last replaced */
private $_lastMessage;
private $lastMessage;
/**
* Create a new DecoratorPlugin with $replacements.
@@ -66,9 +66,9 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
public function setReplacements($replacements)
{
if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) {
$this->_replacements = (array) $replacements;
$this->replacements = (array) $replacements;
} else {
$this->_replacements = $replacements;
$this->replacements = $replacements;
}
}
@@ -80,7 +80,7 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$this->_restoreMessage($message);
$this->restoreMessage($message);
$to = array_keys($message->getTo());
$address = array_shift($to);
if ($replacements = $this->getReplacementsFor($address)) {
@@ -91,7 +91,7 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
$search, $replace, $body
);
if ($body != $bodyReplaced) {
$this->_originalBody = $body;
$this->originalBody = $body;
$message->setBody($bodyReplaced);
}
@@ -111,12 +111,12 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
$count = 1;
}
}
} else {
} elseif (is_string($body)) {
$bodyReplaced = str_replace($search, $replace, $body, $count);
}
if ($count) {
$this->_originalHeaders[$header->getFieldName()] = $body;
$this->originalHeaders[$header->getFieldName()] = $body;
$header->setFieldBodyModel($bodyReplaced);
}
}
@@ -131,11 +131,11 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
);
if ($body != $bodyReplaced) {
$child->setBody($bodyReplaced);
$this->_originalChildBodies[$child->getId()] = $body;
$this->originalChildBodies[$child->getId()] = $body;
}
}
}
$this->_lastMessage = $message;
$this->lastMessage = $message;
}
}
@@ -155,11 +155,11 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
*/
public function getReplacementsFor($address)
{
if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) {
return $this->_replacements->getReplacementsFor($address);
if ($this->replacements instanceof Swift_Plugins_Decorator_Replacements) {
return $this->replacements->getReplacementsFor($address);
}
return isset($this->_replacements[$address]) ? $this->_replacements[$address] : null;
return $this->replacements[$address] ?? null;
}
/**
@@ -169,36 +169,36 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
{
$this->_restoreMessage($evt->getMessage());
$this->restoreMessage($evt->getMessage());
}
/** Restore a changed message back to its original state */
private function _restoreMessage(Swift_Mime_Message $message)
private function restoreMessage(Swift_Mime_SimpleMessage $message)
{
if ($this->_lastMessage === $message) {
if (isset($this->_originalBody)) {
$message->setBody($this->_originalBody);
$this->_originalBody = null;
if ($this->lastMessage === $message) {
if (isset($this->originalBody)) {
$message->setBody($this->originalBody);
$this->originalBody = null;
}
if (!empty($this->_originalHeaders)) {
if (!empty($this->originalHeaders)) {
foreach ($message->getHeaders()->getAll() as $header) {
if (array_key_exists($header->getFieldName(), $this->_originalHeaders)) {
$header->setFieldBodyModel($this->_originalHeaders[$header->getFieldName()]);
if (array_key_exists($header->getFieldName(), $this->originalHeaders)) {
$header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]);
}
}
$this->_originalHeaders = array();
$this->originalHeaders = array();
}
if (!empty($this->_originalChildBodies)) {
if (!empty($this->originalChildBodies)) {
$children = (array) $message->getChildren();
foreach ($children as $child) {
$id = $child->getId();
if (array_key_exists($id, $this->_originalChildBodies)) {
$child->setBody($this->_originalChildBodies[$id]);
if (array_key_exists($id, $this->originalChildBodies)) {
$child->setBody($this->originalChildBodies[$id]);
}
}
$this->_originalChildBodies = array();
$this->originalChildBodies = array();
}
$this->_lastMessage = null;
$this->lastMessage = null;
}
}
}

View File

@@ -18,9 +18,9 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener
/**
* The sender to impersonate.
*
* @var String
* @var string
*/
private $_sender;
private $sender;
/**
* Create a new ImpersonatePlugin to impersonate $sender.
@@ -29,7 +29,7 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener
*/
public function __construct($sender)
{
$this->_sender = $sender;
$this->sender = $sender;
}
/**
@@ -46,7 +46,7 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener
$headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath());
// replace them with the one to send to
$message->setReturnPath($this->_sender);
$message->setReturnPath($this->sender);
}
/**

View File

@@ -11,12 +11,12 @@
/**
* Does real time logging of Transport level information.
*
* @author Chris Corbyn
* @author Chris Corbyn
*/
class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_Events_TransportChangeListener, Swift_Events_TransportExceptionListener, Swift_Plugins_Logger
{
/** The logger which is delegated to */
private $_logger;
private $logger;
/**
* Create a new LoggerPlugin using $logger.
@@ -25,7 +25,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
*/
public function __construct(Swift_Plugins_Logger $logger)
{
$this->_logger = $logger;
$this->logger = $logger;
}
/**
@@ -35,7 +35,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
*/
public function add($entry)
{
$this->_logger->add($entry);
$this->logger->add($entry);
}
/**
@@ -43,7 +43,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
*/
public function clear()
{
$this->_logger->clear();
$this->logger->clear();
}
/**
@@ -53,7 +53,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
*/
public function dump()
{
return $this->_logger->dump();
return $this->logger->dump();
}
/**
@@ -64,7 +64,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
public function commandSent(Swift_Events_CommandEvent $evt)
{
$command = $evt->getCommand();
$this->_logger->add(sprintf('>> %s', $command));
$this->logger->add(sprintf('>> %s', $command));
}
/**
@@ -75,7 +75,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
public function responseReceived(Swift_Events_ResponseEvent $evt)
{
$response = $evt->getResponse();
$this->_logger->add(sprintf('<< %s', $response));
$this->logger->add(sprintf('<< %s', $response));
}
/**
@@ -86,7 +86,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt)
{
$transportName = get_class($evt->getSource());
$this->_logger->add(sprintf('++ Starting %s', $transportName));
$this->logger->add(sprintf('++ Starting %s', $transportName));
}
/**
@@ -97,7 +97,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
public function transportStarted(Swift_Events_TransportChangeEvent $evt)
{
$transportName = get_class($evt->getSource());
$this->_logger->add(sprintf('++ %s started', $transportName));
$this->logger->add(sprintf('++ %s started', $transportName));
}
/**
@@ -108,7 +108,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt)
{
$transportName = get_class($evt->getSource());
$this->_logger->add(sprintf('++ Stopping %s', $transportName));
$this->logger->add(sprintf('++ Stopping %s', $transportName));
}
/**
@@ -119,7 +119,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
public function transportStopped(Swift_Events_TransportChangeEvent $evt)
{
$transportName = get_class($evt->getSource());
$this->_logger->add(sprintf('++ %s stopped', $transportName));
$this->logger->add(sprintf('++ %s stopped', $transportName));
}
/**
@@ -132,10 +132,10 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
$e = $evt->getException();
$message = $e->getMessage();
$code = $e->getCode();
$this->_logger->add(sprintf('!! %s (code: %s)', $message, $code));
$this->logger->add(sprintf('!! %s (code: %s)', $message, $code));
$message .= PHP_EOL;
$message .= 'Log data:'.PHP_EOL;
$message .= $this->_logger->dump();
$message .= $this->logger->dump();
$evt->cancelBubble();
throw new Swift_TransportException($message, $code, $e->getPrevious());
}

View File

@@ -20,14 +20,14 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
*
* @var array
*/
private $_log = array();
private $log = array();
/**
* Max size of the log.
*
* @var int
*/
private $_size = 0;
private $size = 0;
/**
* Create a new ArrayLogger with a maximum of $size entries.
@@ -36,7 +36,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
*/
public function __construct($size = 50)
{
$this->_size = $size;
$this->size = $size;
}
/**
@@ -46,9 +46,9 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
*/
public function add($entry)
{
$this->_log[] = $entry;
while (count($this->_log) > $this->_size) {
array_shift($this->_log);
$this->log[] = $entry;
while (count($this->log) > $this->size) {
array_shift($this->log);
}
}
@@ -57,7 +57,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
*/
public function clear()
{
$this->_log = array();
$this->log = array();
}
/**
@@ -67,6 +67,6 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
*/
public function dump()
{
return implode(PHP_EOL, $this->_log);
return implode(PHP_EOL, $this->log);
}
}

View File

@@ -16,7 +16,7 @@
class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger
{
/** Whether or not HTML should be output */
private $_isHtml;
private $isHtml;
/**
* Create a new EchoLogger.
@@ -25,7 +25,7 @@ class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger
*/
public function __construct($isHtml = true)
{
$this->_isHtml = $isHtml;
$this->isHtml = $isHtml;
}
/**
@@ -35,7 +35,7 @@ class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger
*/
public function add($entry)
{
if ($this->_isHtml) {
if ($this->isHtml) {
printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '<br />', PHP_EOL);
} else {
printf('%s%s', $entry, PHP_EOL);

View File

@@ -16,7 +16,7 @@
class Swift_Plugins_MessageLogger implements Swift_Events_SendListener
{
/**
* @var array
* @var Swift_Mime_Message[]
*/
private $messages;
@@ -28,7 +28,7 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener
/**
* Get the message list.
*
* @return array
* @return Swift_Mime_Message[]
*/
public function getMessages()
{

View File

@@ -11,36 +11,36 @@
/**
* Makes sure a connection to a POP3 host has been established prior to connecting to SMTP.
*
* @author Chris Corbyn
* @author Chris Corbyn
*/
class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection
{
/** A delegate connection to use (mostly a test hook) */
private $_connection;
private $connection;
/** Hostname of the POP3 server */
private $_host;
private $host;
/** Port number to connect on */
private $_port;
private $port;
/** Encryption type to use (if any) */
private $_crypto;
private $crypto;
/** Username to use (if any) */
private $_username;
private $username;
/** Password to use (if any) */
private $_password;
private $password;
/** Established connection via TCP socket */
private $_socket;
private $socket;
/** Connect timeout in seconds */
private $_timeout = 10;
private $timeout = 10;
/** SMTP Transport to bind to */
private $_transport;
private $transport;
/**
* Create a new PopBeforeSmtpPlugin for $host and $port.
@@ -51,23 +51,9 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*/
public function __construct($host, $port = 110, $crypto = null)
{
$this->_host = $host;
$this->_port = $port;
$this->_crypto = $crypto;
}
/**
* Create a new PopBeforeSmtpPlugin for $host and $port.
*
* @param string $host
* @param int $port
* @param string $crypto as "tls" or "ssl"
*
* @return Swift_Plugins_PopBeforeSmtpPlugin
*/
public static function newInstance($host, $port = 110, $crypto = null)
{
return new self($host, $port, $crypto);
$this->host = $host;
$this->port = $port;
$this->crypto = $crypto;
}
/**
@@ -75,11 +61,11 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*
* @param Swift_Plugins_Pop_Pop3Connection $connection
*
* @return Swift_Plugins_PopBeforeSmtpPlugin
* @return $this
*/
public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection)
{
$this->_connection = $connection;
$this->connection = $connection;
return $this;
}
@@ -91,7 +77,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*/
public function bindSmtp(Swift_Transport $smtp)
{
$this->_transport = $smtp;
$this->transport = $smtp;
}
/**
@@ -99,11 +85,11 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*
* @param int $timeout
*
* @return Swift_Plugins_PopBeforeSmtpPlugin
* @return $this
*/
public function setTimeout($timeout)
{
$this->_timeout = (int) $timeout;
$this->timeout = (int) $timeout;
return $this;
}
@@ -113,11 +99,11 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*
* @param string $username
*
* @return Swift_Plugins_PopBeforeSmtpPlugin
* @return $this
*/
public function setUsername($username)
{
$this->_username = $username;
$this->username = $username;
return $this;
}
@@ -127,11 +113,11 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*
* @param string $password
*
* @return Swift_Plugins_PopBeforeSmtpPlugin
* @return $this
*/
public function setPassword($password)
{
$this->_password = $password;
$this->password = $password;
return $this;
}
@@ -143,29 +129,29 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*/
public function connect()
{
if (isset($this->_connection)) {
$this->_connection->connect();
if (isset($this->connection)) {
$this->connection->connect();
} else {
if (!isset($this->_socket)) {
if (!isset($this->socket)) {
if (!$socket = fsockopen(
$this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout)) {
$this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) {
throw new Swift_Plugins_Pop_Pop3Exception(
sprintf('Failed to connect to POP3 host [%s]: %s', $this->_host, $errstr)
sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr)
);
}
$this->_socket = $socket;
$this->socket = $socket;
if (false === $greeting = fgets($this->_socket)) {
if (false === $greeting = fgets($this->socket)) {
throw new Swift_Plugins_Pop_Pop3Exception(
sprintf('Failed to connect to POP3 host [%s]', trim($greeting))
);
}
$this->_assertOk($greeting);
$this->assertOk($greeting);
if ($this->_username) {
$this->_command(sprintf("USER %s\r\n", $this->_username));
$this->_command(sprintf("PASS %s\r\n", $this->_password));
if ($this->username) {
$this->command(sprintf("USER %s\r\n", $this->username));
$this->command(sprintf("PASS %s\r\n", $this->password));
}
}
}
@@ -176,16 +162,16 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*/
public function disconnect()
{
if (isset($this->_connection)) {
$this->_connection->disconnect();
if (isset($this->connection)) {
$this->connection->disconnect();
} else {
$this->_command("QUIT\r\n");
if (!fclose($this->_socket)) {
$this->command("QUIT\r\n");
if (!fclose($this->socket)) {
throw new Swift_Plugins_Pop_Pop3Exception(
sprintf('POP3 host [%s] connection could not be stopped', $this->_host)
sprintf('POP3 host [%s] connection could not be stopped', $this->host)
);
}
$this->_socket = null;
$this->socket = null;
}
}
@@ -196,8 +182,8 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
*/
public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt)
{
if (isset($this->_transport)) {
if ($this->_transport !== $evt->getTransport()) {
if (isset($this->transport)) {
if ($this->transport !== $evt->getTransport()) {
return;
}
}
@@ -227,26 +213,26 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
{
}
private function _command($command)
private function command($command)
{
if (!fwrite($this->_socket, $command)) {
if (!fwrite($this->socket, $command)) {
throw new Swift_Plugins_Pop_Pop3Exception(
sprintf('Failed to write command [%s] to POP3 host', trim($command))
);
}
if (false === $response = fgets($this->_socket)) {
if (false === $response = fgets($this->socket)) {
throw new Swift_Plugins_Pop_Pop3Exception(
sprintf('Failed to read from POP3 host after command [%s]', trim($command))
);
}
$this->_assertOk($response);
$this->assertOk($response);
return $response;
}
private function _assertOk($response)
private function assertOk($response)
{
if (substr($response, 0, 3) != '+OK') {
throw new Swift_Plugins_Pop_Pop3Exception(
@@ -255,10 +241,10 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
}
}
private function _getHostString()
private function getHostString()
{
$host = $this->_host;
switch (strtolower($this->_crypto)) {
$host = $this->host;
switch (strtolower($this->crypto)) {
case 'ssl':
$host = 'ssl://'.$host;
break;

View File

@@ -11,7 +11,7 @@
/**
* Redirects all email to a single recipient.
*
* @author Fabien Potencier
* @author Fabien Potencier
*/
class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
{
@@ -20,14 +20,14 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*
* @var mixed
*/
private $_recipient;
private $recipient;
/**
* List of regular expression for recipient whitelisting.
*
* @var array
*/
private $_whitelist = array();
private $whitelist = array();
/**
* Create a new RedirectingPlugin.
@@ -37,8 +37,8 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*/
public function __construct($recipient, array $whitelist = array())
{
$this->_recipient = $recipient;
$this->_whitelist = $whitelist;
$this->recipient = $recipient;
$this->whitelist = $whitelist;
}
/**
@@ -48,7 +48,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*/
public function setRecipient($recipient)
{
$this->_recipient = $recipient;
$this->recipient = $recipient;
}
/**
@@ -58,7 +58,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*/
public function getRecipient()
{
return $this->_recipient;
return $this->recipient;
}
/**
@@ -68,7 +68,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*/
public function setWhitelist(array $whitelist)
{
$this->_whitelist = $whitelist;
$this->whitelist = $whitelist;
}
/**
@@ -78,7 +78,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*/
public function getWhitelist()
{
return $this->_whitelist;
return $this->whitelist;
}
/**
@@ -106,9 +106,9 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
}
// Filter remaining headers against whitelist
$this->_filterHeaderSet($headers, 'To');
$this->_filterHeaderSet($headers, 'Cc');
$this->_filterHeaderSet($headers, 'Bcc');
$this->filterHeaderSet($headers, 'To');
$this->filterHeaderSet($headers, 'Cc');
$this->filterHeaderSet($headers, 'Bcc');
// Add each hard coded recipient
$to = $message->getTo();
@@ -116,7 +116,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
$to = array();
}
foreach ((array) $this->_recipient as $recipient) {
foreach ((array) $this->recipient as $recipient) {
if (!array_key_exists($recipient, $to)) {
$message->addTo($recipient);
}
@@ -126,13 +126,13 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
/**
* Filter header set against a whitelist of regular expressions.
*
* @param Swift_Mime_HeaderSet $headerSet
* @param string $type
* @param Swift_Mime_SimpleHeaderSet $headerSet
* @param string $type
*/
private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type)
private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type)
{
foreach ($headerSet->getAll($type) as $headers) {
$headers->setNameAddresses($this->_filterNameAddresses($headers->getNameAddresses()));
$headers->setNameAddresses($this->filterNameAddresses($headers->getNameAddresses()));
}
}
@@ -143,12 +143,12 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*
* @return array
*/
private function _filterNameAddresses(array $recipients)
private function filterNameAddresses(array $recipients)
{
$filtered = array();
foreach ($recipients as $address => $name) {
if ($this->_isWhitelisted($address)) {
if ($this->isWhitelisted($address)) {
$filtered[$address] = $name;
}
}
@@ -163,13 +163,13 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*
* @return bool
*/
protected function _isWhitelisted($recipient)
protected function isWhitelisted($recipient)
{
if (in_array($recipient, (array) $this->_recipient)) {
if (in_array($recipient, (array) $this->recipient)) {
return true;
}
foreach ($this->_whitelist as $pattern) {
foreach ($this->whitelist as $pattern) {
if (preg_match($pattern, $recipient)) {
return true;
}
@@ -185,10 +185,10 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
{
$this->_restoreMessage($evt->getMessage());
$this->restoreMessage($evt->getMessage());
}
private function _restoreMessage(Swift_Mime_Message $message)
private function restoreMessage(Swift_Mime_SimpleMessage $message)
{
// restore original headers
$headers = $message->getHeaders();

View File

@@ -24,9 +24,9 @@ interface Swift_Plugins_Reporter
/**
* Notifies this ReportNotifier that $address failed or succeeded.
*
* @param Swift_Mime_Message $message
* @param string $address
* @param int $result from {@link RESULT_PASS, RESULT_FAIL}
* @param Swift_Mime_SimpleMessage $message
* @param string $address
* @param int $result from {@link RESULT_PASS, RESULT_FAIL}
*/
public function notify(Swift_Mime_Message $message, $address, $result);
public function notify(Swift_Mime_SimpleMessage $message, $address, $result);
}

View File

@@ -20,7 +20,7 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
*
* @var Swift_Plugins_Reporter
*/
private $_reporter;
private $reporter;
/**
* Create a new ReporterPlugin using $reporter.
@@ -29,7 +29,7 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
*/
public function __construct(Swift_Plugins_Reporter $reporter)
{
$this->_reporter = $reporter;
$this->reporter = $reporter;
}
/**
@@ -49,13 +49,13 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
$message = $evt->getMessage();
$failures = array_flip($evt->getFailedRecipients());
foreach ((array) $message->getTo() as $address => $null) {
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
$this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS));
}
foreach ((array) $message->getCc() as $address => $null) {
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
$this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS));
}
foreach ((array) $message->getBcc() as $address => $null) {
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
$this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS));
}
}
}

View File

@@ -20,22 +20,22 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
*
* @var array
*/
private $_failures = array();
private $failures = array();
private $_failures_cache = array();
private $failures_cache = array();
/**
* Notifies this ReportNotifier that $address failed or succeeded.
*
* @param Swift_Mime_Message $message
* @param string $address
* @param int $result from {@link RESULT_PASS, RESULT_FAIL}
* @param Swift_Mime_SimpleMessage $message
* @param string $address
* @param int $result from {@link RESULT_PASS, RESULT_FAIL}
*/
public function notify(Swift_Mime_Message $message, $address, $result)
public function notify(Swift_Mime_SimpleMessage $message, $address, $result)
{
if (self::RESULT_FAIL == $result && !isset($this->_failures_cache[$address])) {
$this->_failures[] = $address;
$this->_failures_cache[$address] = true;
if (self::RESULT_FAIL == $result && !isset($this->failures_cache[$address])) {
$this->failures[] = $address;
$this->failures_cache[$address] = true;
}
}
@@ -46,7 +46,7 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
*/
public function getFailedRecipients()
{
return $this->_failures;
return $this->failures;
}
/**
@@ -54,6 +54,6 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
*/
public function clear()
{
$this->_failures = $this->_failures_cache = array();
$this->failures = $this->failures_cache = array();
}
}

View File

@@ -18,11 +18,11 @@ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter
/**
* Notifies this ReportNotifier that $address failed or succeeded.
*
* @param Swift_Mime_Message $message
* @param string $address
* @param int $result from {@see RESULT_PASS, RESULT_FAIL}
* @param Swift_Mime_SimpleMessage $message
* @param string $address
* @param int $result from {@see RESULT_PASS, RESULT_FAIL}
*/
public function notify(Swift_Mime_Message $message, $address, $result)
public function notify(Swift_Mime_SimpleMessage $message, $address, $result)
{
if (self::RESULT_PASS == $result) {
echo '<div style="color: #fff; background: #006600; padding: 2px; margin: 2px;">'.PHP_EOL;

View File

@@ -29,28 +29,28 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*
* @var Swift_Plugins_Sleeper
*/
private $_sleeper;
private $sleeper;
/**
* The Timer instance which provides the timestamp.
*
* @var Swift_Plugins_Timer
*/
private $_timer;
private $timer;
/**
* The time at which the first email was sent.
*
* @var int
*/
private $_start;
private $start;
/**
* The rate at which messages should be sent.
*
* @var int
*/
private $_rate;
private $rate;
/**
* The mode for throttling.
@@ -59,14 +59,14 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*
* @var int
*/
private $_mode;
private $mode;
/**
* An internal counter of the number of messages sent.
*
* @var int
*/
private $_messages = 0;
private $messages = 0;
/**
* Create a new ThrottlerPlugin.
@@ -78,10 +78,10 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*/
public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null)
{
$this->_rate = $rate;
$this->_mode = $mode;
$this->_sleeper = $sleeper;
$this->_timer = $timer;
$this->rate = $rate;
$this->mode = $mode;
$this->sleeper = $sleeper;
$this->timer = $timer;
}
/**
@@ -92,22 +92,22 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
{
$time = $this->getTimestamp();
if (!isset($this->_start)) {
$this->_start = $time;
if (!isset($this->start)) {
$this->start = $time;
}
$duration = $time - $this->_start;
$duration = $time - $this->start;
switch ($this->_mode) {
case self::BYTES_PER_MINUTE :
$sleep = $this->_throttleBytesPerMinute($duration);
switch ($this->mode) {
case self::BYTES_PER_MINUTE:
$sleep = $this->throttleBytesPerMinute($duration);
break;
case self::MESSAGES_PER_SECOND :
$sleep = $this->_throttleMessagesPerSecond($duration);
case self::MESSAGES_PER_SECOND:
$sleep = $this->throttleMessagesPerSecond($duration);
break;
case self::MESSAGES_PER_MINUTE :
$sleep = $this->_throttleMessagesPerMinute($duration);
case self::MESSAGES_PER_MINUTE:
$sleep = $this->throttleMessagesPerMinute($duration);
break;
default :
default:
$sleep = 0;
break;
}
@@ -125,7 +125,7 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
public function sendPerformed(Swift_Events_SendEvent $evt)
{
parent::sendPerformed($evt);
++$this->_messages;
++$this->messages;
}
/**
@@ -135,8 +135,8 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*/
public function sleep($seconds)
{
if (isset($this->_sleeper)) {
$this->_sleeper->sleep($seconds);
if (isset($this->sleeper)) {
$this->sleeper->sleep($seconds);
} else {
sleep($seconds);
}
@@ -149,8 +149,8 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*/
public function getTimestamp()
{
if (isset($this->_timer)) {
return $this->_timer->getTimestamp();
if (isset($this->timer)) {
return $this->timer->getTimestamp();
}
return time();
@@ -163,9 +163,9 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*
* @return int
*/
private function _throttleBytesPerMinute($timePassed)
private function throttleBytesPerMinute($timePassed)
{
$expectedDuration = $this->getBytesOut() / ($this->_rate / 60);
$expectedDuration = $this->getBytesOut() / ($this->rate / 60);
return (int) ceil($expectedDuration - $timePassed);
}
@@ -177,9 +177,9 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*
* @return int
*/
private function _throttleMessagesPerSecond($timePassed)
private function throttleMessagesPerSecond($timePassed)
{
$expectedDuration = $this->_messages / ($this->_rate);
$expectedDuration = $this->messages / $this->rate;
return (int) ceil($expectedDuration - $timePassed);
}
@@ -191,9 +191,9 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
*
* @return int
*/
private function _throttleMessagesPerMinute($timePassed)
private function throttleMessagesPerMinute($timePassed)
{
$expectedDuration = $this->_messages / ($this->_rate / 60);
$expectedDuration = $this->messages / ($this->rate / 60);
return (int) ceil($expectedDuration - $timePassed);
}