Skip to content

Commit 28a7820

Browse files
authored
Merge pull request #639 from barbushin/Fix-pipeline-issues
Fix pipeline issues
2 parents 284aa72 + 8bce5df commit 28a7820

17 files changed

+234
-153
lines changed

.github/workflows/php.yml

+7-31
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,13 @@ on:
77
branches: [ develop ]
88

99
jobs:
10-
provide_php_versions_json:
11-
runs-on: ubuntu-20.04
12-
13-
steps:
14-
# git clone + use PHP + composer install
15-
- uses: actions/checkout@v2
16-
- uses: shivammathur/setup-php@v2
17-
with:
18-
php-version: 8.0
19-
20-
- uses: "ramsey/composer-install@v1"
21-
22-
# to see the output
23-
- run: vendor/bin/easy-ci php-versions-json
24-
25-
# here we create the json, we need the "id:" so we can use it in "outputs" bellow
26-
-
27-
id: output_data
28-
run: echo "::set-output name=matrix::$(vendor/bin/easy-ci php-versions-json)"
29-
30-
# here, we save the result of this 1st phase to the "outputs"
31-
outputs:
32-
matrix: ${{ steps.output_data.outputs.matrix }}
33-
3410
static-analysis:
3511
name: Static Analysis PHP ${{ matrix.php-versions }}
3612
runs-on: ${{ matrix.operating-system }}
37-
needs: provide_php_versions_json
3813
strategy:
3914
matrix:
40-
operating-system: ['ubuntu-latest', 'ubuntu-20.04']
41-
php-versions: ${{ fromJson(needs.provide_php_versions_json.outputs.matrix) }}
15+
operating-system: ['ubuntu-20.04']
16+
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
4217

4318
steps:
4419
- name: Setup PHP
@@ -66,6 +41,7 @@ jobs:
6641
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
6742
restore-keys: |
6843
${{ runner.os }}-composer-
44+
6945
- name: Install dependencies
7046
if: steps.composer-cache.outputs.cache-hit != 'true'
7147
run: composer install --prefer-dist --no-progress --no-suggest
@@ -76,11 +52,10 @@ jobs:
7652
phpunit:
7753
name: PHP ${{ matrix.php-versions }} Unit Tests
7854
runs-on: ${{ matrix.operating-system }}
79-
needs: provide_php_versions_json
8055
strategy:
8156
matrix:
82-
operating-system: ['ubuntu-latest', 'ubuntu-20.04']
83-
php-versions: ${{ fromJson(needs.provide_php_versions_json.outputs.matrix) }}
57+
operating-system: ['ubuntu-20.04']
58+
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
8459

8560
steps:
8661
- name: Setup PHP
@@ -108,6 +83,7 @@ jobs:
10883
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
10984
restore-keys: |
11085
${{ runner.os }}-composer-
86+
11187
- name: Install dependencies
11288
if: steps.composer-cache.outputs.cache-hit != 'true'
11389
run: composer install --prefer-dist --no-progress --no-suggest
@@ -156,6 +132,6 @@ jobs:
156132
- name: Run tests
157133
uses: paambaati/[email protected]
158134
env:
159-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
135+
CC_TEST_REPORTER_ID: "945dfb58a832d233a3caeb84e3e6d3be212e8c7abcb48117fce63b9adcb43647"
160136
with:
161137
coverageCommand: ./vendor/bin/phpunit --testdox --stop-on-failure --coverage-clover=clover.xml

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"ext-mbstring": "*"
3131
},
3232
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "~3.0.0",
33+
"friendsofphp/php-cs-fixer": "^3.4",
3434
"maglnet/composer-require-checker": "^2.0|^3.2",
3535
"nikic/php-parser": "^4.3,<4.7|^4.10",
3636
"paragonie/hidden-string": "^1.0",
@@ -39,15 +39,13 @@
3939
"povils/phpmnd": "^2.2",
4040
"psalm/plugin-phpunit": "^0.10.0|^0.15.1",
4141
"roave/security-advisories": "dev-master",
42-
"sebastian/phpcpd": "^4.1|^6.0",
43-
"symfony/symfony": "^5.4",
44-
"symplify/easy-ci": "^9.4",
45-
"vimeo/psalm": "^4.7"
42+
"sebastian/phpcpd": "^4.1|^6.0"
4643
},
4744
"scripts": {
4845
"static-analysis": [
4946
"parallel-lint .php-cs-fixer.dist.php src tests examples",
5047
"phpcpd src tests",
48+
"composer-require-checker check --config-file=composer-require-checker.config.json ./composer.json",
5149
"phpmnd ./ --exclude=./.github/ --exclude=./examples/ --exclude=./vendor/ --non-zero-exit-on-violation --hint",
5250
"php-cs-fixer fix --allow-risky=yes --no-interaction --dry-run -v",
5351
"psalm --show-info=false"

psalm.xml

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
<?xml version="1.0"?>
22
<psalm
3-
totallyTyped="true"
4-
findUnusedCode="true"
5-
resolveFromConfigFile="true"
6-
requireVoidReturnType="true"
73
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
84
xmlns="https://getpsalm.org/schema/config"
9-
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
5+
name="Psalm for php-imap"
6+
useDocblockTypes="true"
7+
errorLevel="1"
8+
strictBinaryOperands="false"
9+
rememberPropertyAssignmentsAfterCall="true"
10+
checkForThrowsDocblock="false"
11+
throwExceptionOnError="0"
12+
findUnusedCode="false"
13+
ensureArrayStringOffsetsExist="true"
14+
ensureArrayIntOffsetsExist="true"
15+
resolveFromConfigFile="true"
16+
xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd"
17+
limitMethodComplexity="true"
1018
errorBaseline="./psalm.baseline.xml"
1119
cacheDirectory="./psalm/cache/"
20+
findUnusedPsalmSuppress="true"
1221
>
1322
<projectFiles>
1423
<file name="./.php-cs-fixer.dist.php"/>
1524
<directory name="src"/>
16-
<directory name="tests"/>
17-
<directory name="examples"/>
1825
<ignoreFiles>
26+
<directory name="tests"/>
27+
<directory name="examples"/>
1928
<directory name="vendor"/>
2029
</ignoreFiles>
2130
</projectFiles>

src/PhpImap/DataPartInfo.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ protected function convertEncodingAfterFetch(): string
109109
{
110110
if (isset($this->charset) && !empty(\trim($this->charset))) {
111111
$this->data = $this->mail->decodeMimeStr(
112-
(string) $this->data, // Data to convert
113-
\trim($this->charset)
112+
(string) $this->data // Data to convert
114113
);
115114
}
116115

src/PhpImap/Imap.php

+25-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use const SORTSIZE;
2323
use const SORTSUBJECT;
2424
use const SORTTO;
25+
use stdClass;
2526
use Throwable;
2627
use UnexpectedValueException;
2728

@@ -572,6 +573,8 @@ static function (string $folder): string {
572573
* }> $body An indexed array of bodies (docblock is not complete)
573574
*
574575
* @todo flesh out array shape pending resolution of https://github.com/vimeo/psalm/issues/1518
576+
*
577+
* @psalm-pure
575578
*/
576579
public static function mail_compose(array $envelope, array $body): string
577580
{
@@ -647,7 +650,7 @@ public static function mail_move(
647650
/**
648651
* @param false|resource $imap_stream
649652
*/
650-
public static function mailboxmsginfo($imap_stream): object
653+
public static function mailboxmsginfo($imap_stream): stdClass
651654
{
652655
\imap_errors(); // flush errors
653656

@@ -692,7 +695,7 @@ public static function open(
692695
array $params = []
693696
) {
694697
if (\preg_match("/^\{.*\}(.*)$/", $mailbox, $matches)) {
695-
$mailbox_name = $matches[1];
698+
$mailbox_name = $matches[1] ?? '';
696699

697700
if (!\mb_detect_encoding($mailbox_name, 'ASCII', true)) {
698701
$mailbox = static::encodeStringToUtf7Imap($mailbox);
@@ -718,6 +721,8 @@ public static function open(
718721

719722
/**
720723
* @param resource|false $imap_stream
724+
*
725+
* @psalm-pure
721726
*/
722727
public static function ping($imap_stream): bool
723728
{
@@ -892,6 +897,9 @@ public static function setflag_full(
892897
* @param false|resource $imap_stream
893898
*
894899
* @psalm-param value-of<self::SORT_CRITERIA> $criteria
900+
* @psalm-suppress InvalidArgument
901+
*
902+
* @todo InvalidArgument, although it's correct: Argument 3 of imap_sort expects int, bool provided https://www.php.net/manual/de/function.imap-sort.php
895903
*
896904
* @return int[]
897905
*
@@ -908,7 +916,7 @@ public static function sort(
908916
\imap_errors(); // flush errors
909917

910918
$imap_stream = self::EnsureConnection($imap_stream, __METHOD__, 1);
911-
$reverse = (bool) $reverse;
919+
$reverse = $reverse;
912920

913921
/** @var int */
914922
$criteria = $criteria;
@@ -952,11 +960,8 @@ public static function sort(
952960
*
953961
* @psalm-param SA_MESSAGES|SA_RECENT|SA_UNSEEN|SA_UIDNEXT|SA_UIDVALIDITY|SA_ALL $flags
954962
*/
955-
public static function status(
956-
$imap_stream,
957-
string $mailbox,
958-
int $options
959-
): object {
963+
public static function status($imap_stream, string $mailbox, int $options): stdClass
964+
{
960965
$imap_stream = self::EnsureConnection($imap_stream, __METHOD__, 1);
961966

962967
$mailbox = static::encodeStringToUtf7Imap($mailbox);
@@ -975,10 +980,8 @@ public static function status(
975980
/**
976981
* @param false|resource $imap_stream
977982
*/
978-
public static function subscribe(
979-
$imap_stream,
980-
string $mailbox
981-
): void {
983+
public static function subscribe($imap_stream, string $mailbox): void
984+
{
982985
$imap_stream = self::EnsureConnection($imap_stream, __METHOD__, 1);
983986

984987
$mailbox = static::encodeStringToUtf7Imap($mailbox);
@@ -1042,6 +1045,8 @@ public static function unsubscribe(
10421045
* Returns the provided string in UTF7-IMAP encoded format.
10431046
*
10441047
* @return string $str UTF-7 encoded string
1048+
*
1049+
* @psalm-pure
10451050
*/
10461051
public static function encodeStringToUtf7Imap(string $str): string
10471052
{
@@ -1058,6 +1063,8 @@ public static function encodeStringToUtf7Imap(string $str): string
10581063
* Returns the provided string in UTF-8 encoded format.
10591064
*
10601065
* @return string $str, but UTF-8 encoded
1066+
*
1067+
* @psalm-pure
10611068
*/
10621069
public static function decodeStringFromUtf7ImapToUtf8(string $str): string
10631070
{
@@ -1076,6 +1083,8 @@ public static function decodeStringFromUtf7ImapToUtf8(string $str): string
10761083
* @throws InvalidArgumentException if $maybe is not a valid resource
10771084
*
10781085
* @return resource
1086+
*
1087+
* @psalm-pure
10791088
*/
10801089
private static function EnsureResource($maybe, string $method, int $argument)
10811090
{
@@ -1105,6 +1114,8 @@ private static function EnsureConnection($maybe, string $method, int $argument)
11051114

11061115
/**
11071116
* @param array|false $errors
1117+
*
1118+
* @psalm-pure
11081119
*/
11091120
private static function HandleErrors($errors, string $method): UnexpectedValueException
11101121
{
@@ -1117,6 +1128,8 @@ private static function HandleErrors($errors, string $method): UnexpectedValueEx
11171128

11181129
/**
11191130
* @param scalar $msg_number
1131+
*
1132+
* @psalm-pure
11201133
*/
11211134
private static function EnsureRange(
11221135
$msg_number,

src/PhpImap/IncomingMail.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PhpImap;
66

7-
use const FILEINFO_MIME;
7+
use const FILEINFO_MIME_TYPE;
88
use InvalidArgumentException;
99

1010
/**
@@ -169,7 +169,7 @@ public function removeAttachment(string $id): bool
169169
*/
170170
public function getInternalLinksPlaceholders(): array
171171
{
172-
$fetchedHtml = (string) $this->__get('textHtml');
172+
$fetchedHtml = $this->__get('textHtml');
173173

174174
$match = \preg_match_all('/=["\'](ci?d:([\w\.%*@-]+))["\']/i', $fetchedHtml, $matches);
175175

@@ -207,7 +207,7 @@ public function replaceInternalLinks(string $baseUri): string
207207
*/
208208
public function embedImageAttachments(): void
209209
{
210-
$fetchedHtml = (string) $this->__get('textHtml');
210+
$fetchedHtml = $this->__get('textHtml');
211211

212212
\preg_match_all("/\bcid:[^'\"\s]{1,256}/mi", $fetchedHtml, $matches);
213213

@@ -225,7 +225,7 @@ public function embedImageAttachments(): void
225225
*/
226226
if ($attachment->contentId == $cid || 'inline' == \mb_strtolower((string) $attachment->disposition)) {
227227
$contents = $attachment->getContents();
228-
$contentType = (string) $attachment->getFileInfo(FILEINFO_MIME_TYPE);
228+
$contentType = $attachment->getFileInfo(FILEINFO_MIME_TYPE);
229229

230230
if (!\strstr($contentType, 'image')) {
231231
continue;

src/PhpImap/IncomingMailAttachment.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ class IncomingMailAttachment
6767
/** @var string|null */
6868
public $fileExtension;
6969

70+
/** @var string|null */
71+
public $mimeType;
72+
7073
/** @var string|null */
7174
private $file_path;
7275

7376
/** @var DataPartInfo|null */
7477
private $dataInfo;
7578

76-
/** @var string|null */
77-
public $mimeType;
78-
7979
/** @var string|null */
8080
private $filePath;
8181

8282
/**
83-
* @return string|false|null
83+
* @return false|string
8484
*/
8585
public function __get(string $name)
8686
{

0 commit comments

Comments
 (0)