[Web] Minify css and js via PHP

[Web] Use PT Sans
[Web] Update some libs
This commit is contained in:
andryyy
2019-01-30 12:10:26 +01:00
parent 8c433bf0da
commit ad0df77d28
128 changed files with 3698 additions and 631 deletions

View File

@@ -1,5 +1,29 @@
# Change Log
## [1.6.0](https://github.com/ddeboer/imap/tree/1.6.0) (2018-12-04)
[Full Changelog](https://github.com/ddeboer/imap/compare/1.5.5...1.6.0)
**Implemented enhancements:**
- Require PHP ^7.1 [\#257](https://github.com/ddeboer/imap/issues/257)
- Require PHP ^7.1 [\#383](https://github.com/ddeboer/imap/pull/383) ([Slamdunk](https://github.com/Slamdunk))
- Add ability to pass options and retries to imap\_open [\#382](https://github.com/ddeboer/imap/pull/382) ([Slamdunk](https://github.com/Slamdunk))
- Docker setup for running tests [\#374](https://github.com/ddeboer/imap/pull/374) ([LeadTechVisas](https://github.com/LeadTechVisas))
- Get messages by UID sequence [\#373](https://github.com/ddeboer/imap/pull/373) ([LeadTechVisas](https://github.com/LeadTechVisas))
**Fixed bugs:**
- Undeliverable mail: attachment parsing error [\#334](https://github.com/ddeboer/imap/issues/334)
- imap\_getmailboxes returns false; [\#134](https://github.com/ddeboer/imap/issues/134)
- Fix mailbox name as only numbers [\#381](https://github.com/ddeboer/imap/pull/381) ([Slamdunk](https://github.com/Slamdunk))
- Gracefully handle possible non-array return value of imap\_getmailboxes [\#372](https://github.com/ddeboer/imap/pull/372) ([Slamdunk](https://github.com/Slamdunk))
**Closed issues:**
- \[AUTHENTICATIONFAILED\] Authentication failed - Too many login failures [\#368](https://github.com/ddeboer/imap/issues/368)
- last folder in list [\#353](https://github.com/ddeboer/imap/issues/353)
- Caching IMAP server connections [\#88](https://github.com/ddeboer/imap/issues/88)
## [1.5.5](https://github.com/ddeboer/imap/tree/1.5.5) (2018-08-21)
[Full Changelog](https://github.com/ddeboer/imap/compare/1.5.4...1.5.5)

View File

@@ -6,7 +6,7 @@
[![Latest Stable Version](https://poser.pugx.org/ddeboer/imap/v/stable.svg)](https://packagist.org/packages/ddeboer/imap)
[![Total Downloads](https://poser.pugx.org/ddeboer/imap/downloads.png)](https://packagist.org/packages/ddeboer/imap)
A PHP 7.0+ library to read and process e-mails over IMAP.
A PHP 7.1+ library to read and process e-mails over IMAP.
This library requires [IMAP](https://secure.php.net/manual/en/book.imap.php),
[iconv](https://secure.php.net/manual/en/book.iconv.php) and
@@ -27,6 +27,7 @@ This library requires [IMAP](https://secure.php.net/manual/en/book.imap.php),
1. [Timeouts](#timeouts)
1. [Mock the library](#mock-the-library)
1. [Running the Tests](#running-the-tests)
1. [Running Tests using Docker](#running-tests-using-docker)
## Installation
@@ -345,3 +346,11 @@ these environment variables in it:
```
**WARNING** Tests create new mailboxes without removing them.
### Running Tests using Docker
If you have Docker installed you can run the tests locally with the following command:
```
$ docker-compose run tests
```

View File

@@ -22,17 +22,17 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.1",
"ext-iconv": "*",
"ext-imap": "*",
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.10",
"friendsofphp/php-cs-fixer": "^2.13",
"phpstan/phpstan": "^0.9.1",
"phpstan/phpstan-phpunit": "^0.9.3",
"phpunit/phpunit": "^6.5 || ^7.0",
"zendframework/zend-mail": "^2.8"
"phpunit/phpunit": "^7.4",
"zendframework/zend-mail": "^2.10"
},
"autoload": {
"psr-4": {

View File

@@ -6,6 +6,7 @@ namespace Ddeboer\Imap;
use Ddeboer\Imap\Exception\CreateMailboxException;
use Ddeboer\Imap\Exception\DeleteMailboxException;
use Ddeboer\Imap\Exception\ImapGetmailboxesException;
use Ddeboer\Imap\Exception\InvalidResourceException;
use Ddeboer\Imap\Exception\MailboxDoesNotExistException;
@@ -92,7 +93,7 @@ final class Connection implements ConnectionInterface
if (null === $this->mailboxes) {
$this->mailboxes = [];
foreach ($this->mailboxNames as $mailboxName => $mailboxInfo) {
$this->mailboxes[$mailboxName] = $this->getMailbox($mailboxName);
$this->mailboxes[(string) $mailboxName] = $this->getMailbox((string) $mailboxName);
}
}
@@ -181,7 +182,7 @@ final class Connection implements ConnectionInterface
*
* @throws DeleteMailboxException
*/
public function deleteMailbox(MailboxInterface $mailbox)
public function deleteMailbox(MailboxInterface $mailbox): void
{
if (false === \imap_deletemailbox($this->resource->getStream(), $mailbox->getFullEncodedName())) {
throw new DeleteMailboxException(\sprintf('Mailbox "%s" could not be deleted', $mailbox->getName()));
@@ -194,7 +195,7 @@ final class Connection implements ConnectionInterface
/**
* Get mailbox names.
*/
private function initMailboxNames()
private function initMailboxNames(): void
{
if (null !== $this->mailboxNames) {
return;
@@ -202,6 +203,10 @@ final class Connection implements ConnectionInterface
$this->mailboxNames = [];
$mailboxesInfo = \imap_getmailboxes($this->resource->getStream(), $this->server, '*');
if (!\is_array($mailboxesInfo)) {
throw new ImapGetmailboxesException('imap_getmailboxes failed');
}
foreach ($mailboxesInfo as $mailboxInfo) {
$name = \mb_convert_encoding(\str_replace($this->server, '', $mailboxInfo->name), 'UTF-8', 'UTF7-IMAP');
$this->mailboxNames[$name] = $mailboxInfo;

View File

@@ -78,5 +78,5 @@ interface ConnectionInterface extends \Countable
*
* @param MailboxInterface $mailbox
*/
public function deleteMailbox(MailboxInterface $mailbox);
public function deleteMailbox(MailboxInterface $mailbox): void;
}

View File

@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Ddeboer\Imap\Exception;
final class ImapGetmailboxesException extends AbstractException
{
}

View File

@@ -59,7 +59,7 @@ final class ImapResource implements ImapResourceInterface
/**
* Clear last mailbox used cache.
*/
public function clearLastMailboxUsedCache()
public function clearLastMailboxUsedCache(): void
{
self::$lastMailboxUsedCache = null;
}
@@ -67,7 +67,7 @@ final class ImapResource implements ImapResourceInterface
/**
* If connection is not currently in this mailbox, switch it to this mailbox.
*/
private function initMailbox()
private function initMailbox(): void
{
if (null === $this->mailbox || $this->isMailboxOpen()) {
return;

View File

@@ -16,5 +16,5 @@ interface ImapResourceInterface
/**
* Clear last mailbox used cache.
*/
public function clearLastMailboxUsedCache();
public function clearLastMailboxUsedCache(): void;
}

View File

@@ -178,6 +178,31 @@ final class Mailbox implements MailboxInterface
return new MessageIterator($this->resource, $messageNumbers);
}
/**
* Get message iterator for a sequence.
*
* @param string $sequence Message numbers
*
* @return MessageIteratorInterface
*/
public function getMessageSequence(string $sequence): MessageIteratorInterface
{
\imap_errors();
$overview = \imap_fetch_overview($this->resource->getStream(), $sequence, FT_UID);
if (empty($overview)) {
if (false !== \imap_last_error()) {
throw new InvalidSearchCriteriaException(\sprintf('Invalid sequence [%s]', $sequence));
}
$messageNumbers = [];
} else {
$messageNumbers = \array_column($overview, 'uid');
}
return new MessageIterator($this->resource, $messageNumbers);
}
/**
* Get a message by message number.
*
@@ -250,7 +275,7 @@ final class Mailbox implements MailboxInterface
*
* @throws \Ddeboer\Imap\Exception\MessageMoveException
*/
public function move($numbers, MailboxInterface $mailbox)
public function move($numbers, MailboxInterface $mailbox): void
{
if (!\imap_mail_move($this->resource->getStream(), $this->prepareMessageIds($numbers), $mailbox->getEncodedName(), \CP_UID)) {
throw new MessageMoveException(\sprintf('Messages cannot be moved to "%s"', $mailbox->getName()));
@@ -265,7 +290,7 @@ final class Mailbox implements MailboxInterface
*
* @throws \Ddeboer\Imap\Exception\MessageCopyException
*/
public function copy($numbers, MailboxInterface $mailbox)
public function copy($numbers, MailboxInterface $mailbox): void
{
if (!\imap_mail_copy($this->resource->getStream(), $this->prepareMessageIds($numbers), $mailbox->getEncodedName(), \CP_UID)) {
throw new MessageCopyException(\sprintf('Messages cannot be copied to "%s"', $mailbox->getName()));

View File

@@ -85,6 +85,15 @@ interface MailboxInterface extends \Countable, \IteratorAggregate
*/
public function getMessages(ConditionInterface $search = null, int $sortCriteria = null, bool $descending = false): MessageIteratorInterface;
/**
* Get message iterator for a sequence.
*
* @param string $sequence Message numbers
*
* @return MessageIteratorInterface
*/
public function getMessageSequence(string $sequence): MessageIteratorInterface;
/**
* Get a message by message number.
*
@@ -127,7 +136,7 @@ interface MailboxInterface extends \Countable, \IteratorAggregate
*
* @throws \Ddeboer\Imap\Exception\MessageMoveException
*/
public function move($numbers, self $mailbox);
public function move($numbers, self $mailbox): void;
/**
* Bulk copy messages.
@@ -137,5 +146,5 @@ interface MailboxInterface extends \Countable, \IteratorAggregate
*
* @throws \Ddeboer\Imap\Exception\MessageCopyException
*/
public function copy($numbers, self $mailbox);
public function copy($numbers, self $mailbox): void;
}

View File

@@ -55,7 +55,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
/**
* Lazy load structure.
*/
protected function lazyLoadStructure()
protected function lazyLoadStructure(): void
{
if (true === $this->structureLoaded) {
return;
@@ -95,7 +95,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
*
* @param int $messageNumber
*/
protected function assertMessageExists(int $messageNumber)
protected function assertMessageExists(int $messageNumber): void
{
if (true === $this->messageNumberVerified) {
return;
@@ -166,7 +166,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
/**
* Clearmessage headers.
*/
private function clearHeaders()
private function clearHeaders(): void
{
$this->headers = null;
}
@@ -176,7 +176,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
*
* @return null|string
*/
public function isRecent()
public function isRecent(): ?string
{
return $this->getHeaders()->get('recent');
}
@@ -272,7 +272,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
*
* @throws MessageCopyException
*/
public function copy(MailboxInterface $mailbox)
public function copy(MailboxInterface $mailbox): void
{
// 'deleted' header changed, force to reload headers, would be better to set deleted flag to true on header
$this->clearHeaders();
@@ -289,7 +289,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
*
* @throws MessageMoveException
*/
public function move(MailboxInterface $mailbox)
public function move(MailboxInterface $mailbox): void
{
// 'deleted' header changed, force to reload headers, would be better to set deleted flag to true on header
$this->clearHeaders();
@@ -304,7 +304,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
*
* @throws MessageDeleteException
*/
public function delete()
public function delete(): void
{
// 'deleted' header changed, force to reload headers, would be better to set deleted flag to true on header
$this->clearHeaders();

View File

@@ -27,7 +27,7 @@ abstract class AbstractMessage extends AbstractPart
*
* @return null|string
*/
final public function getId()
final public function getId(): ?string
{
return $this->getHeaders()->get('message_id');
}
@@ -37,7 +37,7 @@ abstract class AbstractMessage extends AbstractPart
*
* @return null|EmailAddress
*/
final public function getFrom()
final public function getFrom(): ?EmailAddress
{
$from = $this->getHeaders()->get('from');
@@ -109,7 +109,7 @@ abstract class AbstractMessage extends AbstractPart
*
* @return null|\DateTimeImmutable
*/
final public function getDate()
final public function getDate(): ?\DateTimeImmutable
{
$dateHeader = $this->getHeaders()->get('date');
if (null === $dateHeader) {
@@ -149,7 +149,7 @@ abstract class AbstractMessage extends AbstractPart
*
* @return null|string
*/
final public function getSubject()
final public function getSubject(): ?string
{
return $this->getHeaders()->get('subject');
}
@@ -183,7 +183,7 @@ abstract class AbstractMessage extends AbstractPart
*
* @return null|string
*/
final public function getBodyHtml()
final public function getBodyHtml(): ?string
{
$iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $part) {
@@ -205,7 +205,7 @@ abstract class AbstractMessage extends AbstractPart
*
* @return null|string
*/
final public function getBodyText()
final public function getBodyText(): ?string
{
$iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $part) {

View File

@@ -166,14 +166,14 @@ abstract class AbstractPart implements PartInterface
*
* @param int $messageNumber
*/
protected function assertMessageExists(int $messageNumber)
protected function assertMessageExists(int $messageNumber): void
{
}
/**
* @param \stdClass $structure Part structure
*/
final protected function setStructure(\stdClass $structure)
final protected function setStructure(\stdClass $structure): void
{
$this->structure = $structure;
}
@@ -193,7 +193,7 @@ abstract class AbstractPart implements PartInterface
/**
* Lazy load structure.
*/
protected function lazyLoadStructure()
protected function lazyLoadStructure(): void
{
}
@@ -214,7 +214,7 @@ abstract class AbstractPart implements PartInterface
*
* @return null|string
*/
final public function getCharset()
final public function getCharset(): ?string
{
$this->lazyParseStructure();
@@ -226,7 +226,7 @@ abstract class AbstractPart implements PartInterface
*
* @return null|string
*/
final public function getType()
final public function getType(): ?string
{
$this->lazyParseStructure();
@@ -238,7 +238,7 @@ abstract class AbstractPart implements PartInterface
*
* @return null|string
*/
final public function getSubtype()
final public function getSubtype(): ?string
{
$this->lazyParseStructure();
@@ -250,7 +250,7 @@ abstract class AbstractPart implements PartInterface
*
* @return null|string
*/
final public function getEncoding()
final public function getEncoding(): ?string
{
$this->lazyParseStructure();
@@ -262,7 +262,7 @@ abstract class AbstractPart implements PartInterface
*
* @return null|string
*/
final public function getDisposition()
final public function getDisposition(): ?string
{
$this->lazyParseStructure();
@@ -272,7 +272,7 @@ abstract class AbstractPart implements PartInterface
/**
* Part bytes.
*
* @return null|string
* @return null|int|string
*/
final public function getBytes()
{
@@ -286,7 +286,7 @@ abstract class AbstractPart implements PartInterface
*
* @return null|string
*/
final public function getLines()
final public function getLines(): ?string
{
$this->lazyParseStructure();
@@ -470,7 +470,7 @@ abstract class AbstractPart implements PartInterface
/**
* Parse part structure.
*/
private function lazyParseStructure()
private function lazyParseStructure(): void
{
if (true === $this->structureParsed) {
return;

View File

@@ -16,7 +16,7 @@ final class Attachment extends AbstractPart implements AttachmentInterface
*
* @return null|string
*/
public function getFilename()
public function getFilename(): ?string
{
return $this->getParameters()->get('filename')
?: $this->getParameters()->get('name');

View File

@@ -14,7 +14,7 @@ interface AttachmentInterface extends PartInterface
*
* @return null|string
*/
public function getFilename();
public function getFilename(): ?string;
/**
* Get attachment file size.

View File

@@ -34,14 +34,14 @@ interface BasicMessageInterface extends PartInterface
*
* @return null|string
*/
public function getId();
public function getId(): ?string;
/**
* Get message sender (from headers).
*
* @return null|EmailAddress
*/
public function getFrom();
public function getFrom(): ?EmailAddress;
/**
* Get To recipients.
@@ -90,21 +90,21 @@ interface BasicMessageInterface extends PartInterface
*
* @return null|\DateTimeImmutable
*/
public function getDate();
public function getDate(): ?\DateTimeImmutable;
/**
* Get message size (from headers).
*
* @return int
* @return null|int|string
*/
public function getSize();
/**
* Get message subject (from headers).
*
* @return string
* @return null|string
*/
public function getSubject();
public function getSubject(): ?string;
/**
* Get message In-Reply-To (from headers).
@@ -123,16 +123,16 @@ interface BasicMessageInterface extends PartInterface
/**
* Get body HTML.
*
* @return string | null Null if message has no HTML message part
* @return null|string Null if message has no HTML message part
*/
public function getBodyHtml();
public function getBodyHtml(): ?string;
/**
* Get body text.
*
* @return string
* @return null|string
*/
public function getBodyText();
public function getBodyText(): ?string;
/**
* Get attachments (if any) linked to this e-mail.

View File

@@ -27,7 +27,7 @@ class Parameters extends \ArrayIterator
/**
* @param array $parameters
*/
public function add(array $parameters = [])
public function add(array $parameters = []): void
{
foreach ($parameters as $parameter) {
$key = \strtolower($parameter->attribute);

View File

@@ -40,42 +40,42 @@ interface PartInterface extends \RecursiveIterator
/**
* Part charset.
*
* @return string
* @return null|string
*/
public function getCharset();
public function getCharset(): ?string;
/**
* Part type.
*
* @return null|string
*/
public function getType();
public function getType(): ?string;
/**
* Part subtype.
*
* @return null|string
*/
public function getSubtype();
public function getSubtype(): ?string;
/**
* Part encoding.
*
* @return null|string
*/
public function getEncoding();
public function getEncoding(): ?string;
/**
* Part disposition.
*
* @return null|string
*/
public function getDisposition();
public function getDisposition(): ?string;
/**
* Part bytes.
*
* @return null|string
* @return null|int|string
*/
public function getBytes();
@@ -84,7 +84,7 @@ interface PartInterface extends \RecursiveIterator
*
* @return null|string
*/
public function getLines();
public function getLines(): ?string;
/**
* Part parameters.

View File

@@ -21,7 +21,7 @@ interface MessageInterface extends Message\BasicMessageInterface
*
* @return null|string
*/
public function isRecent();
public function isRecent(): ?string;
/**
* Get message unseen flag value (from headers).
@@ -86,19 +86,19 @@ interface MessageInterface extends Message\BasicMessageInterface
*
* @param MailboxInterface $mailbox
*/
public function copy(MailboxInterface $mailbox);
public function copy(MailboxInterface $mailbox): void;
/**
* Move message to another mailbox.
*
* @param MailboxInterface $mailbox
*/
public function move(MailboxInterface $mailbox);
public function move(MailboxInterface $mailbox): void;
/**
* Delete message.
*/
public function delete();
public function delete(): void;
/**
* Set Flag Message.

View File

@@ -31,6 +31,16 @@ final class Server implements ServerInterface
*/
private $parameters;
/**
* @var int Connection options
*/
private $options;
/**
* @var int Retries number
*/
private $retries;
/**
* Constructor.
*
@@ -39,12 +49,16 @@ final class Server implements ServerInterface
* @param string $port TCP port number
* @param string $flags Optional flags
* @param array $parameters Connection parameters
* @param int $options Connection options
* @param int $retries Retries number
*/
public function __construct(
string $hostname,
string $port = '993',
string $flags = '/imap/ssl/validate-cert',
array $parameters = []
array $parameters = [],
int $options = 0,
int $retries = 1
) {
if (!\function_exists('imap_open')) {
throw new \RuntimeException('IMAP extension must be enabled');
@@ -54,6 +68,8 @@ final class Server implements ServerInterface
$this->port = $port;
$this->flags = $flags ? '/' . \ltrim($flags, '/') : '';
$this->parameters = $parameters;
$this->options = $options;
$this->retries = $retries;
}
/**
@@ -79,8 +95,8 @@ final class Server implements ServerInterface
$this->getServerString(),
$username,
$password,
0,
1,
$this->options,
$this->retries,
$this->parameters
);