', $body['To']);
+ $this->assertSame('Hello!', $body['Subject']);
+ $this->assertSame('Hello There!', $body['TextBody']);
+
+ return new MockResponse(json_encode(['MessageID' => 'foobar']), [
+ 'http_code' => 200,
+ ]);
+ });
+
+ $transport = new PostmarkApiTransport('KEY', $client);
+
+ $mail = new Email();
+ $mail->subject('Hello!')
+ ->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
+ ->from(new Address('fabpot@symfony.com', 'Fabien'))
+ ->text('Hello There!');
+
+ $message = $transport->send($mail);
+
+ $this->assertSame('foobar', $message->getMessageId());
+ }
+
+ public function testSendThrowsForErrorResponse()
+ {
+ $client = new MockHttpClient(static function (string $method, string $url, array $options): ResponseInterface {
+ return new MockResponse(json_encode(['Message' => 'i\'m a teapot', 'ErrorCode' => 418]), [
+ 'http_code' => 418,
+ 'response_headers' => [
+ 'content-type' => 'application/json',
+ ],
+ ]);
+ });
+ $transport = new PostmarkApiTransport('KEY', $client);
+ $transport->setPort(8984);
+
+ $mail = new Email();
+ $mail->subject('Hello!')
+ ->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
+ ->from(new Address('fabpot@symfony.com', 'Fabien'))
+ ->text('Hello There!');
+
+ $this->expectException(HttpTransportException::class);
+ $this->expectExceptionMessage('Unable to send an email: i\'m a teapot (code 418).');
+ $transport->send($mail);
+ }
}
diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php
index b6d9ba282750..bd955934b04c 100644
--- a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php
+++ b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php
@@ -26,7 +26,7 @@ class PostmarkSmtpTransport extends EsmtpTransport
{
public function __construct(string $id, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
- parent::__construct('smtp.postmarkapp.com', 587, true, $dispatcher, $logger);
+ parent::__construct('smtp.postmarkapp.com', 587, false, $dispatcher, $logger);
$this->setUsername($id);
$this->setPassword($id);
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php
index ae9a76fe2208..b73a3a196b50 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php
@@ -207,7 +207,40 @@ public function testEncodedSkipsNonEncodeableStamps()
$encoded = $serializer->encode($envelope);
$this->assertStringNotContainsString('DummySymfonySerializerNonSendableStamp', print_r($encoded['headers'], true));
}
+
+ public function testDecodingFailedConstructorDeserialization()
+ {
+ $serializer = new Serializer();
+
+ $this->expectException(MessageDecodingFailedException::class);
+
+ $serializer->decode([
+ 'body' => '{}',
+ 'headers' => ['type' => DummySymfonySerializerInvalidConstructor::class],
+ ]);
+ }
+
+ public function testDecodingStampFailedDeserialization()
+ {
+ $serializer = new Serializer();
+
+ $this->expectException(MessageDecodingFailedException::class);
+
+ $serializer->decode([
+ 'body' => '{"message":"hello"}',
+ 'headers' => [
+ 'type' => DummyMessage::class,
+ 'X-Message-Stamp-'.SerializerStamp::class => '[{}]',
+ ],
+ ]);
+ }
}
class DummySymfonySerializerNonSendableStamp implements NonSendableStampInterface
{
}
+class DummySymfonySerializerInvalidConstructor
+{
+ public function __construct(string $missingArgument)
+ {
+ }
+}
diff --git a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php
index d5d4d74031df..2b4017e946ce 100644
--- a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php
+++ b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php
@@ -85,13 +85,13 @@ public static function buildConfiguration(string $dsn, array $options = []): arr
// check for extra keys in options
$optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($optionsExtraKeys)) {
- throw new InvalidArgumentException(sprintf('Unknown option found : [%s]. Allowed options are [%s]', implode(', ', $optionsExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
+ throw new InvalidArgumentException(sprintf('Unknown option found : [%s]. Allowed options are [%s]', implode(', ', $optionsExtraKeys), implode(', ', array_keys(self::DEFAULT_OPTIONS))));
}
// check for extra keys in options
$queryExtraKeys = array_diff(array_keys($query), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($queryExtraKeys)) {
- throw new InvalidArgumentException(sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s]', implode(', ', $queryExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
+ throw new InvalidArgumentException(sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s]', implode(', ', $queryExtraKeys), implode(', ', array_keys(self::DEFAULT_OPTIONS))));
}
return $configuration;
diff --git a/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php b/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php
index 2dfcb1bb8369..8d466500fd9a 100644
--- a/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php
+++ b/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php
@@ -19,7 +19,7 @@
use Symfony\Component\Messenger\Stamp\StampInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
-use Symfony\Component\Serializer\Exception\UnexpectedValueException;
+use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer as SymfonySerializer;
@@ -79,7 +79,7 @@ public function decode(array $encodedEnvelope): Envelope
try {
$message = $this->serializer->deserialize($encodedEnvelope['body'], $encodedEnvelope['headers']['type'], $this->format, $context);
- } catch (UnexpectedValueException $e) {
+ } catch (ExceptionInterface $e) {
throw new MessageDecodingFailedException(sprintf('Could not decode message: %s.', $e->getMessage()), $e->getCode(), $e);
}
@@ -117,7 +117,7 @@ private function decodeStamps(array $encodedEnvelope): array
try {
$stamps[] = $this->serializer->deserialize($value, substr($name, \strlen(self::STAMP_HEADER_PREFIX)).'[]', $this->format, $this->context);
- } catch (UnexpectedValueException $e) {
+ } catch (ExceptionInterface $e) {
throw new MessageDecodingFailedException(sprintf('Could not decode stamp: %s.', $e->getMessage()), $e->getCode(), $e);
}
}
diff --git a/src/Symfony/Component/Security/Core/User/ChainUserProvider.php b/src/Symfony/Component/Security/Core/User/ChainUserProvider.php
index 462a44e0cfb6..af5a0ebb0c8d 100644
--- a/src/Symfony/Component/Security/Core/User/ChainUserProvider.php
+++ b/src/Symfony/Component/Security/Core/User/ChainUserProvider.php
@@ -91,7 +91,7 @@ public function refreshUser(UserInterface $user)
$e->setUsername($user->getUsername());
throw $e;
} else {
- throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', \get_class($user)));
+ throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', \get_class($user)));
}
}
diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
index d8a157e80b14..0c8abb9dbecb 100644
--- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
+++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
@@ -268,7 +268,7 @@ protected function refreshUser(TokenInterface $token): ?TokenInterface
return null;
}
- throw new \RuntimeException(sprintf('There is no user provider for user "%s".', $userClass));
+ throw new \RuntimeException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', $userClass));
}
private function safelyUnserialize(string $serializedToken)
diff --git a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php
index 55fd885918ba..7cbd418e2981 100644
--- a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php
+++ b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php
@@ -234,7 +234,7 @@ final protected function getUserProvider(string $class): UserProviderInterface
}
}
- throw new UnsupportedUserException(sprintf('There is no user provider that supports class "%s".', $class));
+ throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', $class));
}
/**
diff --git a/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php b/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php
index 74ecf02cf39c..2a8d3f4f56ee 100644
--- a/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php
+++ b/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php
@@ -48,7 +48,13 @@ public function __construct(string $class, string $name)
*/
public function getPropertyValue($object)
{
- return $this->getReflectionMember($object)->getValue($object);
+ $reflProperty = $this->getReflectionMember($object);
+
+ if (\PHP_VERSION_ID >= 70400 && !$reflProperty->isInitialized($object)) {
+ return null;
+ }
+
+ return $reflProperty->getValue($object);
}
/**
diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/Entity_74.php b/src/Symfony/Component/Validator/Tests/Fixtures/Entity_74.php
new file mode 100644
index 000000000000..cb22fb7f7241
--- /dev/null
+++ b/src/Symfony/Component/Validator/Tests/Fixtures/Entity_74.php
@@ -0,0 +1,8 @@
+expectException('Symfony\Component\Validator\Exception\ValidatorException');
$metadata->getPropertyValue($entity);
}
+
+ /**
+ * @requires PHP 7.4
+ */
+ public function testGetPropertyValueFromUninitializedProperty()
+ {
+ $entity = new Entity_74();
+ $metadata = new PropertyMetadata(self::CLASSNAME_74, 'uninitialized');
+
+ $this->assertNull($metadata->getPropertyValue($entity));
+ }
}
diff --git a/src/Symfony/Component/VarDumper/Caster/ClassStub.php b/src/Symfony/Component/VarDumper/Caster/ClassStub.php
index 758fe57bb4a1..c998b49f2cc4 100644
--- a/src/Symfony/Component/VarDumper/Caster/ClassStub.php
+++ b/src/Symfony/Component/VarDumper/Caster/ClassStub.php
@@ -56,7 +56,7 @@ public function __construct(string $identifier, $callable = null)
}
if (false !== strpos($identifier, "class@anonymous\0")) {
- $this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
+ $this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $identifier);
}
diff --git a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
index 214026b01ba4..9229bdd6b74e 100644
--- a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
+++ b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
@@ -283,7 +283,7 @@ private static function filterExceptionArray(string $xClass, array $a, string $x
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) {
- $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
+ $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $a[Caster::PREFIX_PROTECTED.'message']);
}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy