', $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 b6d9ba2827501..bd955934b04ce 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 ae9a76fe2208d..b73a3a196b504 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 d5d4d74031dfd..2b4017e946ce5 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 2dfcb1bb83692..8d466500fd9a6 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/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php
index dd1009142b14f..19dad6889bd55 100644
--- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php
+++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php
@@ -58,7 +58,7 @@ public function __construct(iterable $voters = [], string $strategy = self::STRA
public function decide(TokenInterface $token, array $attributes, $object = null)
{
if (\count($attributes) > 1) {
- @trigger_error(sprintf('Passing more than one Security attribute to %s() is deprecated since Symfony 4.4. Use multiple decide() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', __METHOD__), E_USER_DEPRECATED);
+ @trigger_error(sprintf('Passing more than one Security attribute to %s() is deprecated since Symfony 4.4. Use multiple decide() calls or the expression language (e.g. "is_granted(...) or is_granted(...)") instead.', __METHOD__), E_USER_DEPRECATED);
}
return $this->{$this->strategy}($token, $attributes, $object);
diff --git a/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php b/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php
index a17ef2337cc84..21f06a1a66d8b 100644
--- a/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php
+++ b/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php
@@ -56,7 +56,7 @@ final public function isGranted($attributes, $subject = null): bool
if (!\is_array($attributes)) {
$attributes = [$attributes];
} else {
- @trigger_error(sprintf('Passing an array of Security attributes to %s() is deprecated since Symfony 4.4. Use multiple isGranted() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', __METHOD__), E_USER_DEPRECATED);
+ @trigger_error(sprintf('Passing an array of Security attributes to %s() is deprecated since Symfony 4.4. Use multiple isGranted() calls or the expression language (e.g. "is_granted(...) or is_granted(...)") instead.', __METHOD__), E_USER_DEPRECATED);
}
return $this->accessDecisionManager->decide($token, $attributes, $subject);
diff --git a/src/Symfony/Component/Security/Core/User/ChainUserProvider.php b/src/Symfony/Component/Security/Core/User/ChainUserProvider.php
index 16bdcc5a63447..cdce7a9bf677b 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 9193a5c5c48e5..9243119acb1cf 100644
--- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
+++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
@@ -292,7 +292,7 @@ protected function refreshUser(TokenInterface $token)
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 9c9e1c07cc527..869195995bfd3 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 74ecf02cf39c1..2a8d3f4f56eeb 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 0000000000000..cb22fb7f72410
--- /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 758fe57bb4a1b..c998b49f2cc47 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 a2a21a56ea8ce..9fe1e39ae49e0 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