Skip to content

Commit

Permalink
PHPDoc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Apr 1, 2024
1 parent d032c7c commit f5ecf88
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
26 changes: 14 additions & 12 deletions Mail/mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function getParam($name)
* the existing body, else the old body is
* overwritten
*
* @return mixed True on success or PEAR_Error object
* @return PEAR_Error|true True on success or PEAR_Error object
*/
public function setTXTBody($data, $isfile = false, $append = false)
{
Expand All @@ -250,7 +250,7 @@ public function getTXTBody()
* @param bool $isfile A flag that determines whether $data is a
* filename, or a string(false, default)
*
* @return bool True on success or PEAR_Error object
* @return PEAR_Error|true True on success or PEAR_Error object
*/
public function setHTMLBody($data, $isfile = false)
{
Expand Down Expand Up @@ -281,7 +281,7 @@ public function getHTMLBody()
* @param string $charset iCalendar character set
* @param string $encoding Transfer encoding
*
* @return mixed True on success or PEAR_Error object
* @return PEAR_Error|true True on success or PEAR_Error object
* @since 1.9.0
*/
public function setCalendarBody($data, $isfile = false, $append = false,
Expand All @@ -294,6 +294,8 @@ public function setCalendarBody($data, $isfile = false, $append = false,
$this->build_params['calendar_charset'] = $charset;
$this->build_params['calendar_encoding'] = $encoding;
}

return $result;
}

/**
Expand Down Expand Up @@ -324,7 +326,7 @@ public function getCalendarBody()
* @param string $content_id Desired Content-ID of MIME part
* Defaults to generated unique ID
*
* @return bool True on success
* @return PEAR_Error|true True on success, PEAR_Error otherwise
*/
public function addHTMLImage($file,
$c_type = 'application/octet-stream',
Expand Down Expand Up @@ -395,7 +397,7 @@ public function addHTMLImage($file,
* @param array $add_headers Additional part headers. Array keys can be in form
* of <header_name>:<parameter_name>
*
* @return mixed True on success or PEAR_Error object
* @return PEAR_Error|true True on success or PEAR_Error object
*/
public function addAttachment($file,
$c_type = 'application/octet-stream',
Expand Down Expand Up @@ -478,7 +480,7 @@ public function isMultipart()
*
* @param string $file_name Path of file to process
*
* @return string Contents of $file_name
* @return PEAR_Error|string Contents of $file_name
*/
protected function file2str($file_name)
{
Expand Down Expand Up @@ -717,7 +719,7 @@ protected function addAttachmentPart($obj, $value)
* See that function for more info.
* @param bool $overwrite Overwrite the existing headers with new.
*
* @return mixed The complete e-mail or PEAR error object
* @return PEAR_Error|string The complete e-mail or PEAR error object
*/
public function getMessage($separation = null, $params = null, $headers = null,
$overwrite = false
Expand All @@ -742,7 +744,7 @@ public function getMessage($separation = null, $params = null, $headers = null,
* @param array $params The Build parameters passed to the
* get() method. See get() for more info.
*
* @return mixed The e-mail body or PEAR error object
* @return PEAR_Error|string|null The e-mail body or PEAR error object
* @since 1.6.0
*/
public function getMessageBody($params = null)
Expand All @@ -761,7 +763,7 @@ public function getMessageBody($params = null)
* See that function for more info.
* @param bool $overwrite Overwrite the existing headers with new.
*
* @return mixed True or PEAR error object
* @return PEAR_Error|true True or PEAR error object
* @since 1.6.0
*/
public function saveMessage($filename, $params = null, $headers = null, $overwrite = false)
Expand Down Expand Up @@ -806,7 +808,7 @@ public function saveMessage($filename, $params = null, $headers = null, $overwri
* @param array $params The Build parameters passed to the
* get() method. See get() for more info.
*
* @return mixed True or PEAR error object
* @return PEAR_Error|true True or PEAR error object
* @since 1.6.0
*/
public function saveMessageBody($filename, $params = null)
Expand Down Expand Up @@ -854,7 +856,7 @@ public function saveMessageBody($filename, $params = null)
* @param bool $skip_head True if you want to return/save only the message
* without headers
*
* @return mixed The MIME message content string, null or PEAR error object
* @return PEAR_Error|string|null The MIME message content string, null or PEAR error object
*/
public function get($params = null, $filename = null, $skip_head = false)
{
Expand Down Expand Up @@ -1513,7 +1515,7 @@ protected function checkParams()
* the existing body, else the old body is
* overwritten
*
* @return mixed True on success or PEAR_Error object
* @return PEAR_Error|true True on success or PEAR_Error object
*/
protected function setBody($type, $data, $isfile = false, $append = false)
{
Expand Down
38 changes: 16 additions & 22 deletions Mail/mimePart.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ public function __construct($body = '', $params = array())
*
* @param string $boundary Pre-defined boundary string
*
* @return array An associative array containing two elements,
* body and headers. The headers element is itself
* an indexed array. On error returns PEAR error object.
* @return PEAR_Error|array An associative array containing two elements,
* body and headers. The headers element is itself
* an indexed array. On error returns PEAR error object.
*/
public function encode($boundary = null)
{
Expand Down Expand Up @@ -370,8 +370,8 @@ public function encode($boundary = null)
* @param string $boundary Pre-defined boundary string
* @param bool $skip_head True if you don't want to save headers
*
* @return array An associative array containing message headers
* or PEAR error object
* @return PEAR_Error|array An associative array containing message headers
* or PEAR error object
* @since 1.6.0
*/
public function encodeToFile($filename, $boundary = null, $skip_head = false)
Expand Down Expand Up @@ -415,7 +415,7 @@ public function encodeToFile($filename, $boundary = null, $skip_head = false)
* @param string $boundary Pre-defined boundary string
* @param bool $skip_head True if you don't want to save headers
*
* @return array True on sucess or PEAR error object
* @return PEAR_Error|true True on sucess or PEAR error object
*/
protected function encodePartToFile($fh, $boundary = null, $skip_head = false)
{
Expand Down Expand Up @@ -526,7 +526,7 @@ protected function getEncodedData($data, $encoding)
* @param resource $fh Output file handle. If set, data will be
* stored into it instead of returning it
*
* @return string Encoded data or PEAR error object
* @return PEAR_Error|string|null Encoded data or PEAR error object
*/
protected function getEncodedDataFromFile($filename, $encoding, $fh = null)
{
Expand Down Expand Up @@ -592,6 +592,8 @@ protected function getEncodedDataFromFile($filename, $encoding, $fh = null)
if (!$fh) {
return $data;
}

return null;
}

/**
Expand All @@ -606,17 +608,8 @@ protected function getEncodedDataFromFile($filename, $encoding, $fh = null)
*/
public static function quotedPrintableEncode($input , $line_max = 76, $eol = "\r\n")
{
/*
// imap_8bit() is extremely fast, but doesn't handle properly some characters
if (function_exists('imap_8bit') && $line_max == 76) {
$input = preg_replace('/\r?\n/', "\r\n", $input);
$input = imap_8bit($input);
if ($eol != "\r\n") {
$input = str_replace("\r\n", $eol, $input);
}
return $input;
}
*/
// Note: imap_8bit() is fast, but doesn't handle properly some characters

$lines = preg_split("/\r?\n/", $input);
$escape = '=';
$output = '';
Expand Down Expand Up @@ -744,8 +737,7 @@ protected function buildHeaderParam($name, $value, $charset = null,
$headCount++;
}

$headers = implode(';' . $this->eol, $headers);
return $headers;
return implode(';' . $this->eol, $headers);
}

/**
Expand Down Expand Up @@ -1015,7 +1007,7 @@ protected static function explodeQuotedString($delimiter, $string)
$strlen = strlen($string);
$quoted_string = '"(?:[^"\\\\]|\\\\.)*"';

for ($p=$i=0; $i < $strlen; $i++) {
for ($p = $i = 0; $i < $strlen; $i++) {
if ($string[$i] === '"') {
$r = preg_match("/$quoted_string/", $string, $matches, 0, $i);
if (!$r || empty($matches[0])) {
Expand All @@ -1027,7 +1019,9 @@ protected static function explodeQuotedString($delimiter, $string)
$p = $i + 1;
}
}

$result[] = substr($string, $p);

return $result;
}

Expand Down Expand Up @@ -1174,7 +1168,7 @@ public static function encodeQP($str)
public static function encodeMB($str, $charset, $encoding, $prefix_len=0, $eol="\r\n")
{
if (!function_exists('mb_substr') || !function_exists('mb_strlen')) {
return;
return '';
}

$encoding = $encoding == 'base64' ? 'B' : 'Q';
Expand Down

0 comments on commit f5ecf88

Please sign in to comment.