Skip to content

Commit 110add7

Browse files
authored
Merge pull request #634 from barbushin/develop
Develop
2 parents f401d85 + 28a7820 commit 110add7

33 files changed

+589
-361
lines changed

.github/workflows/php.yml

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: PHP Static Analysis & Tests
2+
3+
on:
4+
push:
5+
branches: [ develop, 'issue/592' ]
6+
pull_request:
7+
branches: [ develop ]
8+
9+
jobs:
10+
static-analysis:
11+
name: Static Analysis PHP ${{ matrix.php-versions }}
12+
runs-on: ${{ matrix.operating-system }}
13+
strategy:
14+
matrix:
15+
operating-system: ['ubuntu-20.04']
16+
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
17+
18+
steps:
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php-versions }}
23+
coverage: none
24+
25+
- uses: actions/checkout@v2
26+
27+
- name: Validate composer.json and composer.lock
28+
run: composer validate
29+
30+
- name: Get Composer Cache Directory
31+
id: composer-cache
32+
run: |
33+
echo "::set-output name=dir::$(composer config cache-files-dir)"
34+
35+
- name: Cache Files
36+
uses: actions/cache@v2
37+
with:
38+
path: |
39+
${{ steps.composer-cache.outputs.dir }}
40+
**/.php_cs.cache
41+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-composer-
44+
45+
- name: Install dependencies
46+
if: steps.composer-cache.outputs.cache-hit != 'true'
47+
run: composer install --prefer-dist --no-progress --no-suggest
48+
49+
- name: Run static analysis
50+
run: composer run static-analysis
51+
52+
phpunit:
53+
name: PHP ${{ matrix.php-versions }} Unit Tests
54+
runs-on: ${{ matrix.operating-system }}
55+
strategy:
56+
matrix:
57+
operating-system: ['ubuntu-20.04']
58+
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
59+
60+
steps:
61+
- name: Setup PHP
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: ${{ matrix.php-versions }}
65+
coverage: none
66+
67+
- uses: actions/checkout@v2
68+
69+
- name: Validate composer.json and composer.lock
70+
run: composer validate
71+
72+
- name: Get Composer Cache Directory
73+
id: composer-cache
74+
run: |
75+
echo "::set-output name=dir::$(composer config cache-files-dir)"
76+
77+
- name: Cache Files
78+
uses: actions/cache@v2
79+
with:
80+
path: |
81+
${{ steps.composer-cache.outputs.dir }}
82+
**/.php_cs.cache
83+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
84+
restore-keys: |
85+
${{ runner.os }}-composer-
86+
87+
- name: Install dependencies
88+
if: steps.composer-cache.outputs.cache-hit != 'true'
89+
run: composer install --prefer-dist --no-progress --no-suggest
90+
91+
- name: Run tests
92+
run: ./vendor/bin/phpunit --testdox --stop-on-failure
93+
94+
coverage:
95+
name: Coverage
96+
runs-on: ${{ matrix.operating-system }}
97+
strategy:
98+
matrix:
99+
operating-system: ['ubuntu-20.04']
100+
php-versions: ['8.0']
101+
102+
steps:
103+
- name: Setup PHP
104+
uses: shivammathur/setup-php@v2
105+
with:
106+
php-version: ${{ matrix.php-versions }}
107+
coverage: xdebug
108+
109+
- uses: actions/checkout@v2
110+
111+
- name: Validate composer.json and composer.lock
112+
run: composer validate
113+
114+
- name: Get Composer Cache Directory
115+
id: composer-cache
116+
run: |
117+
echo "::set-output name=dir::$(composer config cache-files-dir)"
118+
119+
- name: Cache Files
120+
uses: actions/cache@v2
121+
with:
122+
path: |
123+
${{ steps.composer-cache.outputs.dir }}
124+
**/.php_cs.cache
125+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
126+
restore-keys: |
127+
${{ runner.os }}-composer-
128+
- name: Install dependencies
129+
if: steps.composer-cache.outputs.cache-hit != 'true'
130+
run: composer install --prefer-dist --no-progress --no-suggest
131+
132+
- name: Run tests
133+
uses: paambaati/[email protected]
134+
env:
135+
CC_TEST_REPORTER_ID: "945dfb58a832d233a3caeb84e3e6d3be212e8c7abcb48117fce63b9adcb43647"
136+
with:
137+
coverageCommand: ./vendor/bin/phpunit --testdox --stop-on-failure --coverage-clover=clover.xml

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
vendor/
33
composer.lock
44
*.phar
5-
.php_cs.cache
5+
.php-cs-fixer.cache
66
coverage/
77
psalm/cache/
88

.php-cs-fixer.dist.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/*
3+
* This document has been generated with
4+
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0.0-rc.1|configurator
5+
* you can change this configuration by importing this file.
6+
*/
7+
return (new PhpCsFixer\Config())
8+
->setRiskyAllowed(true)
9+
->setRules([
10+
'@Symfony' => true,
11+
'@Symfony:risky' => true,
12+
'@PHP71Migration' => true, // @PHP72Migration does not exist
13+
'@PHP71Migration:risky' => true, // @PHP72Migration:risky does not exist
14+
'array_syntax' => ['syntax' => 'short'],
15+
'declare_strict_types' => true,
16+
'global_namespace_import' => [
17+
'import_classes' => true,
18+
'import_constants' => true,
19+
'import_functions' => false,
20+
],
21+
'native_constant_invocation' => true,
22+
'native_function_invocation' => [
23+
'strict' => false,
24+
'include' => ['@compiler_optimized'],
25+
],
26+
'no_superfluous_phpdoc_tags' => true,
27+
'ordered_class_elements' => true,
28+
'ordered_imports' => true,
29+
'php_unit_dedicate_assert' => ['target' => 'newest'],
30+
'php_unit_method_casing' => true,
31+
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
32+
'phpdoc_to_comment' => false,
33+
'void_return' => true,
34+
])
35+
->setFinder(PhpCsFixer\Finder::create()
36+
->exclude('vendor')
37+
->in(__DIR__)
38+
)
39+
;

.php_cs.dist

-43
This file was deleted.

.travis.yml

-57
This file was deleted.

README.md

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

7273
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).
7374

75+
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.
76+
7477
```php
7578
// Create PhpImap\Mailbox instance for all further actions
7679
$mailbox = new PhpImap\Mailbox(
7780
'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder
7881
'[email protected]', // Username for the before configured mailbox
7982
'*********', // Password for the before configured username
8083
__DIR__, // Directory, where attachments will be saved (optional)
81-
'UTF-8' // Server encoding (optional)
84+
'UTF-8', // Server encoding (optional)
85+
true, // Trim leading/ending whitespaces of IMAP path (optional)
86+
false // Attachment filename mode (optional; false = random filename; true = original filename)
8287
);
8388

8489
// set some connection arguments (if appropriate)

composer-require-checker.config.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"symbol-whitelist" : [
3+
"null", "true", "false",
4+
"static", "self", "parent",
5+
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "mixed", "never",
6+
"IMAP\\Connection"
7+
],
8+
"php-core-extensions" : [
9+
"Core",
10+
"date",
11+
"pcre",
12+
"Phar",
13+
"Reflection",
14+
"SPL",
15+
"standard"
16+
],
17+
"scan-files" : []
18+
}

composer.json

+11-12
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,31 @@
2323
"sort-packages": true
2424
},
2525
"require": {
26-
"php": "^7.2 || ^8.0 <8.1",
26+
"php": "^7.2 || ^8.0",
2727
"ext-fileinfo": "*",
2828
"ext-iconv": "*",
2929
"ext-imap": "*",
3030
"ext-mbstring": "*"
3131
},
3232
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "^2.16",
34-
"jakub-onderka/php-parallel-lint": "^1.0",
35-
"maglnet/composer-require-checker": "^2.0",
36-
"nikic/php-parser": "^4.3,<4.7",
33+
"friendsofphp/php-cs-fixer": "^3.4",
34+
"maglnet/composer-require-checker": "^2.0|^3.2",
35+
"nikic/php-parser": "^4.3,<4.7|^4.10",
3736
"paragonie/hidden-string": "^1.0",
38-
"phpunit/phpunit": "^8.5",
37+
"php-parallel-lint/php-parallel-lint": "^1.3",
38+
"phpunit/phpunit": "^8.5|^9.5",
3939
"povils/phpmnd": "^2.2",
40-
"psalm/plugin-phpunit": "^0.10.0",
40+
"psalm/plugin-phpunit": "^0.10.0|^0.15.1",
4141
"roave/security-advisories": "dev-master",
42-
"sebastian/phpcpd": "^4.1",
43-
"vimeo/psalm": "^3.12"
42+
"sebastian/phpcpd": "^4.1|^6.0"
4443
},
4544
"scripts": {
4645
"static-analysis": [
47-
"parallel-lint .php_cs.dist src tests examples",
46+
"parallel-lint .php-cs-fixer.dist.php src tests examples",
4847
"phpcpd src tests",
49-
"composer-require-checker check ./composer.json",
48+
"composer-require-checker check --config-file=composer-require-checker.config.json ./composer.json",
5049
"phpmnd ./ --exclude=./.github/ --exclude=./examples/ --exclude=./vendor/ --non-zero-exit-on-violation --hint",
51-
"php-cs-fixer fix --allow-risky=yes --no-interaction --dry-run --diff-format=udiff -v",
50+
"php-cs-fixer fix --allow-risky=yes --no-interaction --dry-run -v",
5251
"psalm --show-info=false"
5352
],
5453
"tests": [

examples/get_and_parse_all_emails_with_matching_subject.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
false // Do NOT mark emails as seen (optional)
3737
);
3838

39-
echo 'from-name: '.(string) (isset($email->fromName) ? $email->fromName : $email->fromAddress)."\n";
39+
echo 'from-name: '.(string) ($email->fromName ?? $email->fromAddress)."\n";
4040
echo 'from-email: '.(string) $email->fromAddress."\n";
4141
echo 'to: '.(string) $email->toString."\n";
4242
echo 'subject: '.(string) $email->subject."\n";

examples/get_and_parse_all_emails_without_saving_attachments.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
false // Do NOT mark emails as seen (optional)
4747
);
4848

49-
echo 'from-name: '.(string) (isset($email->fromName) ? $email->fromName : $email->fromAddress)."\n";
49+
echo 'from-name: '.(string) ($email->fromName ?? $email->fromAddress)."\n";
5050
echo 'from-email: '.(string) $email->fromAddress."\n";
5151
echo 'to: '.(string) $email->toString."\n";
5252
echo 'subject: '.(string) $email->subject."\n";

0 commit comments

Comments
 (0)