Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
[Swift] various dead code cleanups, simplifications and phpdoc fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Hamon committed Sep 2, 2015
1 parent a16e5a7 commit dae3bc6
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 79 deletions.
Expand Up @@ -22,6 +22,8 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I

/**
* StreamFilters.
*
* @var Swift_StreamFilter[]
*/
private $_filters = array();

Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/CharacterReader/UsAsciiReader.php
Expand Up @@ -67,9 +67,9 @@ public function validateByteSequence($bytes, $size)
$byte = reset($bytes);
if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) {
return 0;
} else {
return -1;
}

return -1;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions lib/classes/Swift/CharacterStream/NgCharacterStream.php
Expand Up @@ -178,10 +178,6 @@ public function read($length)
break;

case Swift_CharacterReader::MAP_TYPE_INVALID:
$end = $this->_currentPos + $length;
$end = $end > $this->_charCount
? $this->_charCount
: $end;
$ret = '';
for (; $this->_currentPos < $length; ++$this->_currentPos) {
if (isset($this->_map[$this->_currentPos])) {
Expand Down
8 changes: 4 additions & 4 deletions lib/classes/Swift/DependencyContainer.php
Expand Up @@ -311,9 +311,9 @@ private function _createNewInstance($itemName)
return $reflector->newInstanceArgs(
$this->createDependenciesFor($itemName)
);
} else {
return $reflector->newInstance();
}

return $reflector->newInstance();
}

/** Create and register a shared instance of $itemName */
Expand Down Expand Up @@ -366,8 +366,8 @@ private function _lookupRecursive($item)
}

return $collection;
} else {
return $this->lookup($item);
}

return $this->lookup($item);
}
}
8 changes: 4 additions & 4 deletions lib/classes/Swift/Mime/Grammar.php
Expand Up @@ -129,11 +129,11 @@ public function getDefinition($name)
{
if (array_key_exists($name, self::$_grammar)) {
return self::$_grammar[$name];
} else {
throw new Swift_RfcComplianceException(
"No such grammar '".$name."' defined."
);
}

throw new Swift_RfcComplianceException(
"No such grammar '".$name."' defined."
);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions lib/classes/Swift/Mime/SimpleMimeEntity.php
Expand Up @@ -602,9 +602,9 @@ protected function _setHeaderFieldModel($field, $model)
$this->_headers->get($field)->setFieldBodyModel($model);

return true;
} else {
return false;
}

return false;
}

/**
Expand All @@ -626,9 +626,9 @@ protected function _setHeaderParameter($field, $parameter, $value)
$this->_headers->get($field)->setParameter($parameter, $value);

return true;
} else {
return false;
}

return false;
}

/**
Expand Down Expand Up @@ -760,9 +760,9 @@ private function _getNeededChildLevel($child, $compoundLevel)
if (isset($filter[$realLevel])
&& isset($filter[$realLevel][$lowercaseType])) {
return $filter[$realLevel][$lowercaseType];
} else {
return $realLevel;
}

return $realLevel;
}

private function _createChild()
Expand Down
10 changes: 5 additions & 5 deletions lib/classes/Swift/Plugins/DecoratorPlugin.php
Expand Up @@ -157,12 +157,12 @@ public function getReplacementsFor($address)
{
if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) {
return $this->_replacements->getReplacementsFor($address);
} else {
return isset($this->_replacements[$address])
? $this->_replacements[$address]
: null
;
}

return isset($this->_replacements[$address])
? $this->_replacements[$address]
: null
;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Plugins/ThrottlerPlugin.php
Expand Up @@ -151,9 +151,9 @@ public function getTimestamp()
{
if (isset($this->_timer)) {
return $this->_timer->getTimestamp();
} else {
return time();
}

return time();
}

/**
Expand Down
20 changes: 8 additions & 12 deletions lib/classes/Swift/Signers/DKIMSigner.php
Expand Up @@ -67,7 +67,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
/**
* Signer identity.
*
* @var unknown_type
* @var string
*/
protected $_signerIdentity;

Expand Down Expand Up @@ -143,13 +143,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
*/
protected $_dkimHeader;

/**
* Hash Handler.
*
* @var hash_ressource
*/
private $_headerHashHandler;

private $_bodyHashHandler;

private $_headerHash;
Expand Down Expand Up @@ -206,7 +199,6 @@ public function reset()
{
$this->_headerHash = null;
$this->_signedHeaders = array();
$this->_headerHashHandler = null;
$this->_bodyHash = null;
$this->_bodyHashHandler = null;
$this->_bodyCanonIgnoreStart = 2;
Expand Down Expand Up @@ -394,7 +386,7 @@ public function setBodySignedLen($len)
/**
* Set the signature timestamp.
*
* @param timestamp $time
* @param int $time A timestamp
*
* @return Swift_Signers_DKIMSigner
*/
Expand All @@ -408,7 +400,7 @@ public function setSignatureTimestamp($time)
/**
* Set the signature expiration timestamp.
*
* @param timestamp $time
* @param int $time A timestamp
*
* @return Swift_Signers_DKIMSigner
*/
Expand Down Expand Up @@ -588,9 +580,13 @@ protected function _addHeader($header, $is_sig = false)
$this->_addToHeaderHash($header);
}

/**
* @deprecated This method is currently useless in this class but it must be
* kept for BC reasons due to its "protected" scope. This method
* might be overriden by custom client code.
*/
protected function _endOfHeaders()
{
//$this->_headerHash=hash_final($this->_headerHashHandler, true);
}

protected function _canonicalizeBody($string)
Expand Down
20 changes: 10 additions & 10 deletions lib/classes/Swift/Signers/DomainKeySigner.php
Expand Up @@ -141,7 +141,7 @@ public static function newInstance($privateKey, $domainName, $selector)
/**
* Resets internal states.
*
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function reset()
{
Expand Down Expand Up @@ -170,7 +170,7 @@ public function reset()
* @throws Swift_IoException
*
* @return int
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function write($bytes)
{
Expand All @@ -188,7 +188,7 @@ public function write($bytes)
*
* @throws Swift_IoException
*
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function commit()
{
Expand All @@ -203,7 +203,7 @@ public function commit()
*
* @param Swift_InputByteStream $is
*
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function bind(Swift_InputByteStream $is)
{
Expand All @@ -221,7 +221,7 @@ public function bind(Swift_InputByteStream $is)
*
* @param Swift_InputByteStream $is
*
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function unbind(Swift_InputByteStream $is)
{
Expand All @@ -243,7 +243,7 @@ public function unbind(Swift_InputByteStream $is)
*
* @throws Swift_IoException
*
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function flushBuffers()
{
Expand All @@ -257,7 +257,7 @@ public function flushBuffers()
*
* @param string $hash
*
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function setHashAlgorithm($hash)
{
Expand All @@ -271,7 +271,7 @@ public function setHashAlgorithm($hash)
*
* @param string $canon simple | nofws defaults to simple
*
* @return Swift_Signers_DomainKeysSigner
* @return Swift_Signers_DomainKeySigner
*/
public function setCanon($canon)
{
Expand Down Expand Up @@ -336,9 +336,9 @@ public function getAlteredHeaders()
{
if ($this->_debugHeaders) {
return array('DomainKey-Signature', 'X-DebugHash');
} else {
return array('DomainKey-Signature');
}

return array('DomainKey-Signature');
}

/**
Expand Down
11 changes: 6 additions & 5 deletions lib/classes/Swift/Signers/OpenDKIMSigner.php
Expand Up @@ -29,11 +29,12 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner

public function __construct($privateKey, $domainName, $selector)
{
if (extension_loaded('opendkim')) {
$this->_peclLoaded = true;
} else {
if (!extension_loaded('opendkim')) {
throw new Swift_SwiftException('php-opendkim extension not found');
}

$this->_peclLoaded = true;

parent::__construct($privateKey, $domainName, $selector);
}

Expand Down Expand Up @@ -130,7 +131,7 @@ public function reset()
/**
* Set the signature timestamp.
*
* @param timestamp $time
* @param int $time
*
* @return Swift_Signers_DKIMSigner
*/
Expand All @@ -144,7 +145,7 @@ public function setSignatureTimestamp($time)
/**
* Set the signature expiration timestamp.
*
* @param timestamp $time
* @param int $time
*
* @return Swift_Signers_DKIMSigner
*/
Expand Down
9 changes: 4 additions & 5 deletions lib/classes/Swift/Signers/SMimeSigner.php
Expand Up @@ -41,9 +41,9 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
/**
* Constructor.
*
* @param string $certificate
* @param string $privateKey
* @param string $encryptCertificate
* @param string|null $signCertificate
* @param string|null $signPrivateKey
* @param string|null $encryptCertificate
*/
public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null)
{
Expand Down Expand Up @@ -167,7 +167,7 @@ public function getSignPrivateKey()
* But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted.
* As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients.
*
* @param string $signThenEncrypt
* @param bool $signThenEncrypt
*
* @return Swift_Signers_SMimeSigner
*/
Expand Down Expand Up @@ -400,7 +400,6 @@ protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Messag
}

$boundary = trim($contentTypeData['1'], '"');
$boundaryLen = strlen($boundary);

// Skip the header and CRLF CRLF
$fromStream->setReadPointer($headersPosEnd + 4);
Expand Down
6 changes: 3 additions & 3 deletions lib/classes/Swift/Transport/AbstractSmtpTransport.php
Expand Up @@ -417,7 +417,7 @@ private function _doMailTransaction($message, $reversePath, array $recipients, a
foreach ($recipients as $forwardPath) {
try {
$this->_doRcptToCommand($forwardPath);
$sent++;
++$sent;
} catch (Swift_TransportException $e) {
$failedRecipients[] = $forwardPath;
}
Expand Down Expand Up @@ -475,9 +475,9 @@ private function _isFqdn($hostname)
// We could do a really thorough check, but there's really no point
if (false !== $dotPos = strpos($hostname, '.')) {
return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1);
} else {
return false;
}

return false;
}

/**
Expand Down
8 changes: 0 additions & 8 deletions lib/classes/Swift/Transport/FailoverTransport.php
Expand Up @@ -22,14 +22,6 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran
*/
private $_currentTransport;

/**
* Creates a new FailoverTransport.
*/
public function __construct()
{
parent::__construct();
}

/**
* Send the given Message.
*
Expand Down
7 changes: 0 additions & 7 deletions lib/classes/Swift/Transport/LoadBalancedTransport.php
Expand Up @@ -29,13 +29,6 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
*/
protected $_transports = array();

/**
* Creates a new LoadBalancedTransport.
*/
public function __construct()
{
}

/**
* Set $transports to delegate to.
*
Expand Down

0 comments on commit dae3bc6

Please sign in to comment.