diff --git a/readme.md b/readme.md
index 3cdfcd33..3ab272ca 100644
--- a/readme.md
+++ b/readme.md
@@ -50,7 +50,7 @@ $mail->setHTMLBody('Sample HTML
');
Embedded images can be inserted using `$mail->addEmbeddedFile('background.gif')`, but it is not necessary.
Why? Because Nette Framework finds and inserts all files referenced in the HTML code automatically.
-This behavior can be supressed by adding `FALSE` as a second parameter of the `setHtmlBody()` method.
+This behavior can be supressed by adding `false` as a second parameter of the `setHtmlBody()` method.
If a HTML e-mail has no plain-text alternative, it will be automatically generated. And if it has no subject set, it will be taken from the `
Codestin Search App#is', function ($m) {
$this->setSubject(html_entity_decode($m[1], ENT_QUOTES, 'UTF-8'));
});
@@ -275,7 +275,7 @@ public function getHtmlBody()
* @param string
* @return MimePart
*/
- public function addEmbeddedFile($file, $content = NULL, $contentType = NULL)
+ public function addEmbeddedFile($file, $content = null, $contentType = null)
{
return $this->inlines[$file] = $this->createAttachment($file, $content, $contentType, 'inline')
->setHeader('Content-ID', $this->getRandomId());
@@ -301,7 +301,7 @@ public function addInlinePart(MimePart $part)
* @param string
* @return MimePart
*/
- public function addAttachment($file, $content = NULL, $contentType = NULL)
+ public function addAttachment($file, $content = null, $contentType = null)
{
return $this->attachments[] = $this->createAttachment($file, $content, $contentType, 'attachment');
}
@@ -320,17 +320,17 @@ public function getAttachments()
/**
* Creates file MIME part.
* @param string
- * @param string|NULL
- * @param string|NULL
+ * @param string|null
+ * @param string|null
* @param string
* @return MimePart
*/
private function createAttachment($file, $content, $contentType, $disposition)
{
$part = new MimePart;
- if ($content === NULL) {
+ if ($content === null) {
$content = @file_get_contents($file); // @ is escalated to exception
- if ($content === FALSE) {
+ if ($content === false) {
throw new Nette\FileNotFoundException("Unable to read file '$file'.");
}
} else {
@@ -415,7 +415,7 @@ protected function buildText($html)
$text = Strings::replace($html, [
'#<(style|script|head).*\\1>#Uis' => '',
'#]#i' => ' $0',
- '#]*href=(?|"([^"]+)"|\'([^\']+)\')[^>]*>(.*?)#is' => '$2 <$1>',
+ '#]*href=(?|"([^"]+)"|\'([^\']+)\')[^>]*>(.*?)#is' => '$2 <$1>',
'#[\r\n]+#' => ' ',
'#<(/?p|/?h\d|li|br|/tr)[ >/]#i' => "\n$0",
]);
@@ -432,5 +432,4 @@ private function getRandomId()
. preg_replace('#[^\w.-]+#', '', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n'))
. '>';
}
-
}
diff --git a/src/Mail/MimePart.php b/src/Mail/MimePart.php
index 9c3789b2..3ef4247a 100644
--- a/src/Mail/MimePart.php
+++ b/src/Mail/MimePart.php
@@ -47,13 +47,13 @@ class MimePart
* @param bool
* @return static
*/
- public function setHeader($name, $value, $append = FALSE)
+ public function setHeader($name, $value, $append = false)
{
if (!$name || preg_match('#[^a-z0-9-]#i', $name)) {
throw new Nette\InvalidArgumentException("Header name must be non-empty alphanumeric string, '$name' given.");
}
- if ($value == NULL) { // intentionally ==
+ if ($value == null) { // intentionally ==
if (!$append) {
unset($this->headers[$name]);
}
@@ -65,7 +65,7 @@ public function setHeader($name, $value, $append = FALSE)
}
foreach ($value as $email => $recipient) {
- if ($recipient === NULL) {
+ if ($recipient === null) {
// continue
} elseif (!Strings::checkEncoding($recipient)) {
Nette\Utils\Validators::assert($recipient, 'unicode', "header '$name'");
@@ -94,7 +94,7 @@ public function setHeader($name, $value, $append = FALSE)
*/
public function getHeader($name)
{
- return isset($this->headers[$name]) ? $this->headers[$name] : NULL;
+ return isset($this->headers[$name]) ? $this->headers[$name] : null;
}
@@ -113,20 +113,20 @@ public function clearHeader($name)
/**
* Returns an encoded header.
* @param string
- * @return string|NULL
+ * @return string|null
*/
public function getEncodedHeader($name)
{
$offset = strlen($name) + 2; // colon + space
if (!isset($this->headers[$name])) {
- return NULL;
+ return null;
} elseif (is_array($this->headers[$name])) {
$s = '';
foreach ($this->headers[$name] as $email => $name) {
- if ($name != NULL) { // intentionally ==
- $s .= self::encodeHeader($name, $offset, TRUE);
+ if ($name != null) { // intentionally ==
+ $s .= self::encodeHeader($name, $offset, true);
$email = " <$email>";
}
$s .= self::append($email . ',', $offset);
@@ -159,7 +159,7 @@ public function getHeaders()
* @param string
* @return static
*/
- public function setContentType($contentType, $charset = NULL)
+ public function setContentType($contentType, $charset = null)
{
$this->setHeader('Content-Type', $contentType . ($charset ? "; charset=$charset" : ''));
return $this;
@@ -192,9 +192,9 @@ public function getEncoding()
* Adds or creates new multipart.
* @return self
*/
- public function addPart(MimePart $part = NULL)
+ public function addPart(MimePart $part = null)
{
- return $this->parts[] = $part === NULL ? new self : $part;
+ return $this->parts[] = $part === null ? new self : $part;
}
@@ -254,7 +254,7 @@ public function getEncodedMessage()
case self::ENCODING_7BIT:
$body = preg_replace('#[\x80-\xFF]+#', '', $body);
- // break intentionally omitted
+ // break omitted
case self::ENCODING_8BIT:
$body = str_replace(["\x00", "\r"], '', $body);
@@ -274,7 +274,7 @@ public function getEncodedMessage()
foreach ($this->parts as $part) {
$output .= '--' . $boundary . self::EOL . $part->getEncodedMessage() . self::EOL;
}
- $output .= '--' . $boundary.'--';
+ $output .= '--' . $boundary . '--';
}
return $output;
@@ -291,7 +291,7 @@ public function getEncodedMessage()
* @param bool
* @return string
*/
- private static function encodeHeader($s, &$offset = 0, $quotes = FALSE)
+ private static function encodeHeader($s, &$offset = 0, $quotes = false)
{
if (strspn($s, "!\"#$%&\'()*+,-./0123456789:;<>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^`abcdefghijklmnopqrstuvwxyz{|}~=? _\r\n\t") === strlen($s)) {
if ($quotes && preg_match('#[^ a-zA-Z0-9!\#$%&\'*+/?^_`{|}~-]#', $s)) { // RFC 2822 atext except =
@@ -327,5 +327,4 @@ private static function append($s, &$offset = 0)
$offset += strlen($s);
return $s;
}
-
}
diff --git a/src/Mail/SendmailMailer.php b/src/Mail/SendmailMailer.php
index ce6718f4..5be3b8df 100644
--- a/src/Mail/SendmailMailer.php
+++ b/src/Mail/SendmailMailer.php
@@ -17,7 +17,7 @@ class SendmailMailer implements IMailer
{
use Nette\SmartObject;
- /** @var string|NULL */
+ /** @var string|null */
public $commandArgs;
@@ -29,8 +29,8 @@ class SendmailMailer implements IMailer
public function send(Message $mail)
{
$tmp = clone $mail;
- $tmp->setHeader('Subject', NULL);
- $tmp->setHeader('To', NULL);
+ $tmp->setHeader('Subject', null);
+ $tmp->setHeader('To', null);
$parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
@@ -46,9 +46,8 @@ public function send(Message $mail)
$res = Nette\Utils\Callback::invokeSafe('mail', $args, function ($message) use (&$info) {
$info = ": $message";
});
- if ($res === FALSE) {
+ if ($res === false) {
throw new SendException("Unable to send email$info.");
}
}
-
}
diff --git a/src/Mail/SmtpMailer.php b/src/Mail/SmtpMailer.php
index e4d3b318..acae6b08 100644
--- a/src/Mail/SmtpMailer.php
+++ b/src/Mail/SmtpMailer.php
@@ -49,7 +49,7 @@ public function __construct(array $options = [])
{
if (isset($options['host'])) {
$this->host = $options['host'];
- $this->port = isset($options['port']) ? (int) $options['port'] : NULL;
+ $this->port = isset($options['port']) ? (int) $options['port'] : null;
} else {
$this->host = ini_get('SMTP');
$this->port = (int) ini_get('smtp_port');
@@ -94,7 +94,7 @@ public function send(Message $mail)
$this->write("RCPT TO:<$email>", [250, 251]);
}
- $mail->setHeader('Bcc', NULL);
+ $mail->setHeader('Bcc', null);
$data = $mail->generateMessage();
$this->write('DATA', 354);
$data = preg_replace('#^\.#m', '..', $data);
@@ -120,7 +120,7 @@ public function send(Message $mail)
*/
protected function connect()
{
- $this->connection = @stream_socket_client( // @ is escalated to exception
+ $this->connection = @stream_socket_client(// @ is escalated to exception
($this->secure === 'ssl' ? 'ssl://' : '') . $this->host . ':' . $this->port,
$errno, $error, $this->timeout, STREAM_CLIENT_CONNECT, $this->context
);
@@ -139,19 +139,19 @@ protected function connect()
if ($this->secure === 'tls') {
$this->write('STARTTLS', 220);
- if (!stream_socket_enable_crypto($this->connection, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
+ if (!stream_socket_enable_crypto($this->connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
throw new SmtpException('Unable to connect via TLS.');
}
$this->write("EHLO $self", 250);
}
- if ($this->username != NULL && $this->password != NULL) {
+ if ($this->username != null && $this->password != null) {
$authMechanisms = [];
if (preg_match('~^250[ -]AUTH (.*)$~im', $ehloResponse, $matches)) {
$authMechanisms = explode(' ', trim($matches[1]));
}
- if (in_array('PLAIN', $authMechanisms, TRUE)) {
+ if (in_array('PLAIN', $authMechanisms, true)) {
$credentials = $this->username . "\0" . $this->username . "\0" . $this->password;
$this->write('AUTH PLAIN ' . base64_encode($credentials), 235, 'PLAIN credentials');
} else {
@@ -170,7 +170,7 @@ protected function connect()
protected function disconnect()
{
fclose($this->connection);
- $this->connection = NULL;
+ $this->connection = null;
}
@@ -181,12 +181,12 @@ protected function disconnect()
* @param string error message
* @return void
*/
- protected function write($line, $expectedCode = NULL, $message = NULL)
+ protected function write($line, $expectedCode = null, $message = null)
{
fwrite($this->connection, $line . Message::EOL);
if ($expectedCode) {
$response = $this->read();
- if (!in_array((int) $response, (array) $expectedCode, TRUE)) {
+ if (!in_array((int) $response, (array) $expectedCode, true)) {
throw new SmtpException('SMTP server did not accept ' . ($message ? $message : $line) . ' with error: ' . trim($response));
}
}
@@ -200,7 +200,7 @@ protected function write($line, $expectedCode = NULL, $message = NULL)
protected function read()
{
$s = '';
- while (($line = fgets($this->connection, 1000)) != NULL) { // intentionally ==
+ while (($line = fgets($this->connection, 1000)) != null) { // intentionally ==
$s .= $line;
if (substr($line, 3, 1) === ' ') {
break;
@@ -208,5 +208,4 @@ protected function read()
}
return $s;
}
-
}
diff --git a/tests/Mail.DI/Mail.extension.phpt b/tests/Mail.DI/Mail.extension.phpt
index 2a66b08a..14a18c3e 100644
--- a/tests/Mail.DI/Mail.extension.phpt
+++ b/tests/Mail.DI/Mail.extension.phpt
@@ -4,8 +4,8 @@
* Test: MailExtension.
*/
-use Nette\DI;
use Nette\Bridges\MailDI\MailExtension;
+use Nette\DI;
use Tester\Assert;
diff --git a/tests/Mail.DI/include.php b/tests/Mail.DI/include.php
index 4bcde277..c866ea52 100644
--- a/tests/Mail.DI/include.php
+++ b/tests/Mail.DI/include.php
@@ -2,10 +2,11 @@
class FooExtension extends Nette\DI\CompilerExtension
-{}
+{
+}
-function createContainer($source, $config = NULL)
+function createContainer($source, $config = null)
{
$loader = new Nette\DI\Config\Loader;
$config = $loader->load(Tester\FileMock::create($config, 'neon'));
diff --git a/tests/Mail/Mail.HtmlBody.phpt b/tests/Mail/Mail.HtmlBody.phpt
index b8e60054..35bf40af 100644
--- a/tests/Mail/Mail.HtmlBody.phpt
+++ b/tests/Mail/Mail.HtmlBody.phpt
@@ -24,7 +24,7 @@ $mail->setHTMLBody('Příliš žluťoučký
kůň');
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<setHTMLBody('Příliš send($mail);
-Assert::match(<<addAttachment(__DIR__ . '/files/example.zip', NULL, 'application/zip');
+$mail->addAttachment(__DIR__ . '/files/example.zip', null, 'application/zip');
$mailer->send($mail);
-Assert::match(<<addAttachment(__DIR__ . '/files/example.zip', NULL, 'application/zip')
+$mail->addAttachment(__DIR__ . '/files/example.zip', null, 'application/zip')
->setEncoding(Message::ENCODING_QUOTED_PRINTABLE);
$mailer->send($mail);
-Assert::match(<<addAttachment($name, file_get_contents(__DIR__ . '/files/example.zip'), 'application/zip');
$mailer->send($mail);
-Assert::match(<<addBcc('veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryv
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<setBody('Žluťoučký kůň');
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<setHeader('X-Gmail-Label', 'love');
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<setBody('Žluťoučký kůň' . str_repeat('x', 990));
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<generateMessage();
}
-
}
diff --git a/tests/Mail/Mail.textualAndHtmlBody.attachment.phpt b/tests/Mail/Mail.textualAndHtmlBody.attachment.phpt
index 24e235b1..0f5a79ce 100644
--- a/tests/Mail/Mail.textualAndHtmlBody.attachment.phpt
+++ b/tests/Mail/Mail.textualAndHtmlBody.attachment.phpt
@@ -23,7 +23,7 @@ $mail->setBody('Sample text');
$mail->setHTMLBody('Sample text');
-$mail->addAttachment(__DIR__ . '/files/example.zip', NULL, 'application/zip');
+$mail->addAttachment(__DIR__ . '/files/example.zip', null, 'application/zip');
$mailer = new TestMailer();
$mailer->send($mail);
diff --git a/tests/Mail/Mail.textualAndHtmlBody.phpt b/tests/Mail/Mail.textualAndHtmlBody.phpt
index 1502ff33..fb9865d9 100644
--- a/tests/Mail/Mail.textualAndHtmlBody.phpt
+++ b/tests/Mail/Mail.textualAndHtmlBody.phpt
@@ -26,7 +26,7 @@ $mail->setHTMLBody('Žluťoučký kůň');
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<setSubject('Hello Jane!');
$mail->setBody('Sample text');
-$mail->addAttachment(__DIR__ . '/files/example.zip', NULL, 'application/zip');
+$mail->addAttachment(__DIR__ . '/files/example.zip', null, 'application/zip');
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<setBody('Žluťoučký kůň');
$mailer = new TestMailer();
$mailer->send($mail);
-Assert::match(<<