Skip to content

Commit

Permalink
Merge pull request #634 from barbushin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Sebbo94BY committed Dec 27, 2021
2 parents f401d85 + 28a7820 commit 110add7
Show file tree
Hide file tree
Showing 33 changed files with 589 additions and 361 deletions.
137 changes: 137 additions & 0 deletions .github/workflows/php.yml
@@ -0,0 +1,137 @@
name: PHP Static Analysis & Tests

on:
push:
branches: [ develop, 'issue/592' ]
pull_request:
branches: [ develop ]

jobs:
static-analysis:
name: Static Analysis PHP ${{ matrix.php-versions }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Files
uses: actions/cache@v2
with:
path: |
${{ steps.composer-cache.outputs.dir }}
**/.php_cs.cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run static analysis
run: composer run static-analysis

phpunit:
name: PHP ${{ matrix.php-versions }} Unit Tests
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Files
uses: actions/cache@v2
with:
path: |
${{ steps.composer-cache.outputs.dir }}
**/.php_cs.cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run tests
run: ./vendor/bin/phpunit --testdox --stop-on-failure

coverage:
name: Coverage
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['8.0']

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug

- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Files
uses: actions/cache@v2
with:
path: |
${{ steps.composer-cache.outputs.dir }}
**/.php_cs.cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run tests
uses: paambaati/codeclimate-action@v2.7.2
env:
CC_TEST_REPORTER_ID: "945dfb58a832d233a3caeb84e3e6d3be212e8c7abcb48117fce63b9adcb43647"
with:
coverageCommand: ./vendor/bin/phpunit --testdox --stop-on-failure --coverage-clover=clover.xml
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -2,7 +2,7 @@
vendor/
composer.lock
*.phar
.php_cs.cache
.php-cs-fixer.cache
coverage/
psalm/cache/

Expand Down
39 changes: 39 additions & 0 deletions .php-cs-fixer.dist.php
@@ -0,0 +1,39 @@
<?php
/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0.0-rc.1|configurator
* you can change this configuration by importing this file.
*/
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration' => true, // @PHP72Migration does not exist
'@PHP71Migration:risky' => true, // @PHP72Migration:risky does not exist
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => false,
],
'native_constant_invocation' => true,
'native_function_invocation' => [
'strict' => false,
'include' => ['@compiler_optimized'],
],
'no_superfluous_phpdoc_tags' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_method_casing' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
'phpdoc_to_comment' => false,
'void_return' => true,
])
->setFinder(PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
)
;
43 changes: 0 additions & 43 deletions .php_cs.dist

This file was deleted.

57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -4,6 +4,7 @@
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Packagist](https://img.shields.io/packagist/dt/php-imap/php-imap.svg?style=flat-square)](https://packagist.org/packages/php-imap/php-imap)
[![Build Status](https://travis-ci.org/barbushin/php-imap.svg?branch=master)](https://travis-ci.org/barbushin/php-imap)
[![CI](https://github.com/barbushin/php-imap/actions/workflows/php.yml/badge.svg)](https://github.com/barbushin/php-imap/actions/workflows/php.yml)
[![Supported PHP Version](https://img.shields.io/packagist/php-v/php-imap/php-imap.svg)](README.md)
[![Maintainability](https://api.codeclimate.com/v1/badges/02f72a4fd695cb7e2976/maintainability)](https://codeclimate.com/github/barbushin/php-imap/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/02f72a4fd695cb7e2976/test_coverage)](https://codeclimate.com/github/barbushin/php-imap/test_coverage)
Expand Down Expand Up @@ -71,14 +72,18 @@ You can run all PHPUnit tests by running the following command (inside of the in

Below, you'll find an example code how you can use this library. For further information and other examples, you may take a look at the [wiki](https://github.com/barbushin/php-imap/wiki).

By default, this library uses random filenames for attachments as identical file names from other emails would overwrite other attachments. If you want to keep the original file name, you can set the attachment filename mode to ``true``, but then you also need to ensure, that those files don't get overwritten by other emails for example.

```php
// Create PhpImap\Mailbox instance for all further actions
$mailbox = new PhpImap\Mailbox(
'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder
'some@gmail.com', // Username for the before configured mailbox
'*********', // Password for the before configured username
__DIR__, // Directory, where attachments will be saved (optional)
'UTF-8' // Server encoding (optional)
'UTF-8', // Server encoding (optional)
true, // Trim leading/ending whitespaces of IMAP path (optional)
false // Attachment filename mode (optional; false = random filename; true = original filename)
);

// set some connection arguments (if appropriate)
Expand Down
18 changes: 18 additions & 0 deletions composer-require-checker.config.json
@@ -0,0 +1,18 @@
{
"symbol-whitelist" : [
"null", "true", "false",
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "mixed", "never",
"IMAP\\Connection"
],
"php-core-extensions" : [
"Core",
"date",
"pcre",
"Phar",
"Reflection",
"SPL",
"standard"
],
"scan-files" : []
}
23 changes: 11 additions & 12 deletions composer.json
Expand Up @@ -23,32 +23,31 @@
"sort-packages": true
},
"require": {
"php": "^7.2 || ^8.0 <8.1",
"php": "^7.2 || ^8.0",
"ext-fileinfo": "*",
"ext-iconv": "*",
"ext-imap": "*",
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"jakub-onderka/php-parallel-lint": "^1.0",
"maglnet/composer-require-checker": "^2.0",
"nikic/php-parser": "^4.3,<4.7",
"friendsofphp/php-cs-fixer": "^3.4",
"maglnet/composer-require-checker": "^2.0|^3.2",
"nikic/php-parser": "^4.3,<4.7|^4.10",
"paragonie/hidden-string": "^1.0",
"phpunit/phpunit": "^8.5",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpunit/phpunit": "^8.5|^9.5",
"povils/phpmnd": "^2.2",
"psalm/plugin-phpunit": "^0.10.0",
"psalm/plugin-phpunit": "^0.10.0|^0.15.1",
"roave/security-advisories": "dev-master",
"sebastian/phpcpd": "^4.1",
"vimeo/psalm": "^3.12"
"sebastian/phpcpd": "^4.1|^6.0"
},
"scripts": {
"static-analysis": [
"parallel-lint .php_cs.dist src tests examples",
"parallel-lint .php-cs-fixer.dist.php src tests examples",
"phpcpd src tests",
"composer-require-checker check ./composer.json",
"composer-require-checker check --config-file=composer-require-checker.config.json ./composer.json",
"phpmnd ./ --exclude=./.github/ --exclude=./examples/ --exclude=./vendor/ --non-zero-exit-on-violation --hint",
"php-cs-fixer fix --allow-risky=yes --no-interaction --dry-run --diff-format=udiff -v",
"php-cs-fixer fix --allow-risky=yes --no-interaction --dry-run -v",
"psalm --show-info=false"
],
"tests": [
Expand Down
Expand Up @@ -36,7 +36,7 @@
false // Do NOT mark emails as seen (optional)
);

echo 'from-name: '.(string) (isset($email->fromName) ? $email->fromName : $email->fromAddress)."\n";
echo 'from-name: '.(string) ($email->fromName ?? $email->fromAddress)."\n";
echo 'from-email: '.(string) $email->fromAddress."\n";
echo 'to: '.(string) $email->toString."\n";
echo 'subject: '.(string) $email->subject."\n";
Expand Down
Expand Up @@ -46,7 +46,7 @@
false // Do NOT mark emails as seen (optional)
);

echo 'from-name: '.(string) (isset($email->fromName) ? $email->fromName : $email->fromAddress)."\n";
echo 'from-name: '.(string) ($email->fromName ?? $email->fromAddress)."\n";
echo 'from-email: '.(string) $email->fromAddress."\n";
echo 'to: '.(string) $email->toString."\n";
echo 'subject: '.(string) $email->subject."\n";
Expand Down

0 comments on commit 110add7

Please sign in to comment.