Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6234adb

Browse files
committed
minor #54280 [Mime] Use CPP (AurelienPillevesse)
This PR was merged into the 7.1 branch. Discussion ---------- [Mime] Use CPP | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Commits ------- d8a32c1 Use CPP - Mime component
2 parents 226bb88 + d8a32c1 commit 6234adb

16 files changed

+64
-92
lines changed

src/Symfony/Component/Mime/Crypto/DkimSigner.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ final class DkimSigner
3131
public const ALGO_ED25519 = 'ed25519-sha256'; // RFC 8463
3232

3333
private \OpenSSLAsymmetricKey $key;
34-
private string $domainName;
35-
private string $selector;
36-
private array $defaultOptions;
3734

3835
/**
3936
* @param string $pk The private key as a string or the path to the file containing the private key, should be prefixed with file:// (in PEM format)
4037
* @param string $passphrase A passphrase of the private key (if any)
4138
*/
42-
public function __construct(string $pk, string $domainName, string $selector, array $defaultOptions = [], string $passphrase = '')
43-
{
39+
public function __construct(
40+
string $pk,
41+
private string $domainName,
42+
private string $selector,
43+
private array $defaultOptions = [],
44+
string $passphrase = '',
45+
) {
4446
if (!\extension_loaded('openssl')) {
4547
throw new \LogicException('PHP extension "openssl" is required to use DKIM.');
4648
}
4749
$this->key = openssl_pkey_get_private($pk, $passphrase) ?: throw new InvalidArgumentException('Unable to load DKIM private key: '.openssl_error_string());
48-
$this->domainName = $domainName;
49-
$this->selector = $selector;
50-
$this->defaultOptions = $defaultOptions + [
50+
$this->defaultOptions += [
5151
'algorithm' => self::ALGO_SHA256,
5252
'signature_expiration_delay' => 0,
5353
'body_max_length' => \PHP_INT_MAX,

src/Symfony/Component/Mime/FileBinaryMimeTypeGuesser.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
*/
2222
class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
2323
{
24-
private string $cmd;
25-
2624
/**
2725
* The $cmd pattern must contain a "%s" string that will be replaced
2826
* with the file name to guess.
@@ -31,9 +29,9 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
3129
*
3230
* @param string $cmd The command to run to get the MIME type of a file
3331
*/
34-
public function __construct(string $cmd = 'file -b --mime -- %s 2>/dev/null')
35-
{
36-
$this->cmd = $cmd;
32+
public function __construct(
33+
private string $cmd = 'file -b --mime -- %s 2>/dev/null',
34+
) {
3735
}
3836

3937
public function isGuesserSupported(): bool

src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@
2121
*/
2222
class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
2323
{
24-
private ?string $magicFile;
25-
2624
/**
2725
* @param string|null $magicFile A magic file to use with the finfo instance
2826
*
2927
* @see http://www.php.net/manual/en/function.finfo-open.php
3028
*/
31-
public function __construct(?string $magicFile = null)
32-
{
33-
$this->magicFile = $magicFile;
29+
public function __construct(
30+
private ?string $magicFile = null,
31+
) {
3432
}
3533

3634
public function isGuesserSupported(): bool

src/Symfony/Component/Mime/Message.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
class Message extends RawMessage
2323
{
2424
private Headers $headers;
25-
private ?AbstractPart $body;
2625

27-
public function __construct(?Headers $headers = null, ?AbstractPart $body = null)
28-
{
26+
public function __construct(
27+
?Headers $headers = null,
28+
private ?AbstractPart $body = null,
29+
) {
2930
$this->headers = $headers ? clone $headers : new Headers();
30-
$this->body = $body;
3131
}
3232

3333
public function __clone()

src/Symfony/Component/Mime/Part/MessagePart.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@
2121
*/
2222
class MessagePart extends DataPart
2323
{
24-
private RawMessage $message;
25-
26-
public function __construct(RawMessage $message)
27-
{
24+
public function __construct(
25+
private RawMessage $message,
26+
) {
2827
if ($message instanceof Message) {
2928
$name = $message->getHeaders()->getHeaderBody('Subject').'.eml';
3029
} else {
3130
$name = 'email.eml';
3231
}
3332
parent::__construct('', $name);
34-
35-
$this->message = $message;
3633
}
3734

3835
public function getMediaType(): string

src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@
2323
*/
2424
final class FormDataPart extends AbstractMultipartPart
2525
{
26-
private array $fields = [];
27-
2826
/**
2927
* @param array<string|array|DataPart> $fields
3028
*/
31-
public function __construct(array $fields = [])
32-
{
29+
public function __construct(
30+
private array $fields = [],
31+
) {
3332
parent::__construct();
3433

35-
$this->fields = $fields;
36-
3734
// HTTP does not support \r\n in header values
3835
$this->getHeaders()->setMaxLineLength(\PHP_INT_MAX);
3936
}

src/Symfony/Component/Mime/Part/Multipart/RelatedPart.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
*/
2020
final class RelatedPart extends AbstractMultipartPart
2121
{
22-
private AbstractPart $mainPart;
23-
24-
public function __construct(AbstractPart $mainPart, AbstractPart $part, AbstractPart ...$parts)
25-
{
26-
$this->mainPart = $mainPart;
22+
public function __construct(
23+
private AbstractPart $mainPart,
24+
AbstractPart $part,
25+
AbstractPart ...$parts,
26+
) {
2727
$this->prepareParts($part, ...$parts);
2828

2929
parent::__construct($part, ...$parts);

src/Symfony/Component/Mime/Part/SMimePart.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,13 @@ class SMimePart extends AbstractPart
2121
/** @internal */
2222
protected Headers $_headers;
2323

24-
private iterable|string $body;
25-
private string $type;
26-
private string $subtype;
27-
private array $parameters;
28-
29-
public function __construct(iterable|string $body, string $type, string $subtype, array $parameters)
30-
{
24+
public function __construct(
25+
private iterable|string $body,
26+
private string $type,
27+
private string $subtype,
28+
private array $parameters,
29+
) {
3130
parent::__construct();
32-
33-
$this->body = $body;
34-
$this->type = $type;
35-
$this->subtype = $subtype;
36-
$this->parameters = $parameters;
3731
}
3832

3933
public function getMediaType(): string

src/Symfony/Component/Mime/RawMessage.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
*/
1919
class RawMessage
2020
{
21-
private iterable|string $message;
2221
private bool $isGeneratorClosed;
2322

24-
public function __construct(iterable|string $message)
25-
{
26-
$this->message = $message;
23+
public function __construct(
24+
private iterable|string $message,
25+
) {
2726
}
2827

2928
public function toString(): string

src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818

1919
final class EmailAddressContains extends Constraint
2020
{
21-
private string $headerName;
22-
private string $expectedValue;
23-
24-
public function __construct(string $headerName, string $expectedValue)
25-
{
26-
$this->headerName = $headerName;
27-
$this->expectedValue = $expectedValue;
21+
public function __construct(
22+
private string $headerName,
23+
private string $expectedValue,
24+
) {
2825
}
2926

3027
public function toString(): string

0 commit comments

Comments
 (0)