Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 17, 2021. It is now read-only.

Commitbc28df7

Browse files
committed
bug#1355 PHP 8.1 Support (driesvints)
This PR was squashed before being merged into the 6.2-dev branch.Discussion----------PHP 8.1 Support| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| Doc update? | no| BC breaks? | no| Deprecations? |no| Fixed tickets || License | MITThis PR updates SwiftMailer to be compatible with PHP 8.1. Additionally, I've migrated the Travis build to GitHub Actions. More tests are being run now thanks to this.The reason why I sent this in is because we'll need this to offer PHP 8.1 support on the mail component in Laravel 8. For the upcoming Laravel 9 release in January 2022 we're switching to Symfony Mailer. I've also manually tested this PR through using the Laravel 8 mail component.I've tried to go over all the pieces of code that I changed in comments below. Thought that was a bit more useful to review.Would love to get feedback on this soon as PHP 8.1 is now fast approaching! 🙂Commits-------ee8a1d9 PHP 8.1 Support
2 parents2a7fb75 +ee8a1d9 commitbc28df7

File tree

29 files changed

+158
-97
lines changed

29 files changed

+158
-97
lines changed

‎.github/workflows/tests.yml‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name:tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
linux_tests:
9+
runs-on:ubuntu-20.04
10+
11+
services:
12+
mailcatcher:
13+
image:dockage/mailcatcher:0.7.1
14+
ports:
15+
-4456:1025
16+
17+
strategy:
18+
fail-fast:true
19+
matrix:
20+
php:['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
21+
22+
name:PHP ${{ matrix.php }}
23+
24+
steps:
25+
-name:Checkout code
26+
uses:actions/checkout@v2
27+
28+
-name:Setup PHP
29+
uses:shivammathur/setup-php@v2
30+
with:
31+
php-version:${{ matrix.php }}
32+
extensions:dom, curl, libxml, mbstring, zip, intl
33+
tools:composer:v2
34+
coverage:none
35+
36+
-name:Prepare test config files
37+
run:|
38+
cp tests/acceptance.conf.php.default tests/acceptance.conf.php
39+
cp tests/smoke.conf.php.default tests/smoke.conf.php
40+
41+
-name:Require Symfony PHPUnit Bridge 5.4 for PHP 8.1
42+
if:${{ matrix.php >= 8.1 }}
43+
run:composer require symfony/phpunit-bridge:^5.4 --dev --prefer-dist --no-interaction --no-progress
44+
45+
-name:Install dependencies
46+
uses:nick-invision/retry@v1
47+
with:
48+
timeout_minutes:5
49+
max_attempts:5
50+
command:composer update --prefer-stable --prefer-dist --no-interaction --no-progress
51+
52+
-name:Execute tests
53+
run:vendor/bin/simple-phpunit --verbose
54+
env:
55+
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT:1

‎.travis.yml‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎composer.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"require-dev": {
2525
"mockery/mockery":"^1.0",
26-
"symfony/phpunit-bridge":"^4.4|^5.0"
26+
"symfony/phpunit-bridge":"^4.4|^5.4"
2727
},
2828
"suggest": {
2929
"ext-intl":"Needed to support internationalized email addresses"
@@ -38,5 +38,7 @@
3838
"branch-alias": {
3939
"dev-master":"6.2-dev"
4040
}
41-
}
41+
},
42+
"minimum-stability":"dev",
43+
"prefer-stable":true
4244
}

‎lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function init()
103103
*/
104104
publicfunctiongetReaderFor($charset)
105105
{
106-
$charset =strtolower(trim($charset));
106+
$charset =strtolower(trim($charset ??''));
107107
foreach (self::$mapas$pattern =>$spec) {
108108
$re ='/^'.$pattern.'$/D';
109109
if (preg_match($re,$charset)) {

‎lib/classes/Swift/Encoder/Base64Encoder.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
3434
$maxLineLength =76;
3535
}
3636

37-
$encodedString =base64_encode($string);
37+
$encodedString =base64_encode($string ??'');
3838
$firstLine ='';
3939

4040
if (0 !=$firstLineOffset) {

‎lib/classes/Swift/Message.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ protected function saveMessage()
224224
protectedfunctionsaveHeaders(array$altered)
225225
{
226226
foreach ($alteredas$head) {
227-
$lc =strtolower($head);
227+
$lc =strtolower($head ??'');
228228

229229
if (!isset($this->savedMessage['headers'][$lc])) {
230230
$this->savedMessage['headers'][$lc] =$this->getHeaders()->getAll($head);

‎lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre
2727
}
2828

2929
$remainder =0;
30-
$base64ReadBufferRemainderBytes =null;
30+
$base64ReadBufferRemainderBytes ='';
3131

3232
// To reduce memory usage, the output buffer is streamed to the input buffer like so:
3333
// Output Stream => base64encode => wrap line length => Input Stream
@@ -45,7 +45,7 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre
4545
}else {
4646
$streamTheseBytes =$base64ReadBufferRemainderBytes.$readBytes;
4747
}
48-
$base64ReadBufferRemainderBytes =null;
48+
$base64ReadBufferRemainderBytes ='';
4949
$bytesLength =\strlen($streamTheseBytes);
5050

5151
if (0 ===$bytesLength) {// no data left to encode

‎lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function getName()
4141
*/
4242
publicfunctionencodeString($string,$firstLineOffset =0,$maxLineLength =0,$charset ='utf-8')
4343
{
44-
if ('iso-2022-jp' ===strtolower($charset)) {
44+
if ('iso-2022-jp' ===strtolower($charset ??'')) {
4545
$old =mb_internal_encoding();
4646
mb_internal_encoding('utf-8');
4747
$newstring =mb_encode_mimeheader($string,$charset,$this->getName(),"\r\n");

‎lib/classes/Swift/Mime/Headers/AbstractHeader.php‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ protected function getEncodableWordTokens($string)
309309

310310
$encodedToken ='';
311311
// Split at all whitespace boundaries
312-
foreach (preg_split('~(?=[\t ])~',$string)as$token) {
312+
foreach (preg_split('~(?=[\t ])~',$string ??'')as$token) {
313313
if ($this->tokenNeedsEncoding($token)) {
314314
$encodedToken .=$token;
315315
}else {
@@ -354,10 +354,10 @@ protected function getTokenAsEncodedWord($token, $firstLineOffset = 0)
354354
$encodedTextLines =explode("\r\n",
355355
$this->encoder->encodeString(
356356
$token,$firstLineOffset,75 -$encodingWrapperLength,$this->charset
357-
)
357+
) ??''
358358
);
359359

360-
if ('iso-2022-jp' !==strtolower($this->charset)) {
360+
if ('iso-2022-jp' !==strtolower($this->charset ??'')) {
361361
// special encoding for iso-2022-jp using mb_encode_mimeheader
362362
foreach ($encodedTextLinesas$lineNum =>$line) {
363363
$encodedTextLines[$lineNum] ='=?'.$charsetDecl.
@@ -378,7 +378,7 @@ protected function getTokenAsEncodedWord($token, $firstLineOffset = 0)
378378
*/
379379
protectedfunctiongenerateTokenLines($token)
380380
{
381-
returnpreg_split('~(\r\n)~',$token, -1,PREG_SPLIT_DELIM_CAPTURE);
381+
returnpreg_split('~(\r\n)~',$token ??'', -1,PREG_SPLIT_DELIM_CAPTURE);
382382
}
383383

384384
/**
@@ -429,7 +429,7 @@ protected function toTokens($string = null)
429429
$tokens = [];
430430

431431
// Generate atoms; split at all invisible boundaries followed by WSP
432-
foreach (preg_split('~(?=[ \t])~',$string)as$token) {
432+
foreach (preg_split('~(?=[ \t])~',$string ??'')as$token) {
433433
$newTokens =$this->generateTokenLines($token);
434434
foreach ($newTokensas$newToken) {
435435
$tokens[] =$newToken;
@@ -473,4 +473,14 @@ private function tokensToString(array $tokens)
473473
// Implode with FWS (RFC 2822, 2.2.3)
474474
returnimplode("\r\n",$headerLines)."\r\n";
475475
}
476+
477+
/**
478+
* Make a deep copy of object.
479+
*/
480+
publicfunction__clone()
481+
{
482+
if ($this->encoder) {
483+
$this->encoder =clone$this->encoder;
484+
}
485+
}
476486
}

‎lib/classes/Swift/Mime/MimePart.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ protected function setNestingLevel($level)
189189
/** Encode charset when charset is not utf-8 */
190190
protectedfunctionconvertString($string)
191191
{
192-
$charset =strtolower($this->getCharset());
192+
$charset =strtolower($this->getCharset() ??'');
193193
if (!\in_array($charset, ['utf-8','iso-8859-1','iso-8859-15',''])) {
194194
returnmb_convert_encoding($string,$charset,'utf-8');
195195
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp