Merge branch '4.3' into 4.4

* 4.3:
  [Serializer] Fix DataUriNormalizer deprecation (MIME type guesser is optional)
  [DependencyInjection] fix the ValidateEnvPlaceHolderPassTest that was using a deprecated path for TreeBuilder
  avoid service id conflicts with Swiftmailer
  [Form] fix usage of legacy TranslatorInterface
  [Serializer] Fix DataUriNormalizer docblock & composer suggest section
This commit is contained in:
Nicolas Grekas 2019-06-07 16:29:38 +02:00
commit 3d9e884642
8 changed files with 27 additions and 18 deletions

View File

@ -1916,7 +1916,7 @@ class FrameworkExtension extends Extension
}
$loader->load('mailer.xml');
$container->getDefinition('mailer.transport')->setArgument(0, $config['dsn']);
$container->getDefinition('mailer.default_transport')->setArgument(0, $config['dsn']);
}
/**

View File

@ -6,23 +6,23 @@
<services>
<service id="mailer.mailer" class="Symfony\Component\Mailer\Mailer">
<argument type="service" id="mailer.transport" />
<argument type="service" id="mailer.default_transport" />
<argument type="service" id="messenger.default_bus" on-invalid="ignore" />
</service>
<service id="mailer" alias="mailer.mailer" />
<service id="Symfony\Component\Mailer\MailerInterface" alias="mailer.mailer" />
<service id="mailer.transport" class="Symfony\Component\Mailer\Transport\TransportInterface">
<service id="mailer.default_transport" class="Symfony\Component\Mailer\Transport\TransportInterface">
<factory class="Symfony\Component\Mailer\Transport" method="fromDsn" />
<argument /> <!-- env(MAILER_DSN) -->
<argument type="service" id="event_dispatcher" />
<argument type="service" id="http_client" on-invalid="ignore" />
<argument type="service" id="logger" on-invalid="ignore" />
</service>
<service id="Symfony\Component\Mailer\Transport\TransportInterface" alias="mailer.transport" />
<service id="Symfony\Component\Mailer\Transport\TransportInterface" alias="mailer.default_transport" />
<service id="mailer.messenger.message_handler" class="Symfony\Component\Mailer\Messenger\MessageHandler">
<argument type="service" id="mailer.transport" />
<argument type="service" id="mailer.default_transport" />
<tag name="messenger.message_handler" />
</service>
</services>

View File

@ -392,7 +392,7 @@ class EnvConfigurationWithoutRootNode implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
return new TreeBuilder();
return new TreeBuilder('env_extension');
}
}
@ -400,8 +400,8 @@ class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInte
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$treeBuilder->root('env_extension')
$treeBuilder = new TreeBuilder('env_extension');
$treeBuilder->getRootNode()
->children()
->arrayNode('nodes')
->isRequired()

View File

@ -20,7 +20,8 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class FileType extends AbstractType
{
@ -35,8 +36,14 @@ class FileType extends AbstractType
private $translator;
public function __construct(TranslatorInterface $translator = null)
/**
* @param TranslatorInterface|null $translator
*/
public function __construct($translator = null)
{
if (null !== $translator && !$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
}
$this->translator = $translator;
}

View File

@ -17,7 +17,7 @@ use Symfony\Component\Form\NativeRequestHandler;
use Symfony\Component\Form\RequestHandlerInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class FileTypeTest extends BaseTypeTest
{

View File

@ -34,12 +34,12 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
];
/**
* @var MimeTypeGuesserInterface
* @var MimeTypeGuesserInterface|null
*/
private $mimeTypeGuesser;
/**
* @param MimeTypeGuesserInterface
* @param MimeTypeGuesserInterface|null $mimeTypeGuesser
*/
public function __construct($mimeTypeGuesser = null)
{
@ -48,8 +48,8 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
} elseif (null === $mimeTypeGuesser) {
if (class_exists(MimeTypes::class)) {
$mimeTypeGuesser = MimeTypes::getDefault();
} else {
@trigger_error(sprintf('Passing null to "%s()" without symfony/mime installed is deprecated since Symfony 4.3, install symfony/mime.', __METHOD__), E_USER_DEPRECATED);
} elseif (class_exists(MimeTypeGuesser::class)) {
@trigger_error(sprintf('Passing null to "%s()" to use a default MIME type guesser without Symfony Mime installed is deprecated since Symfony 4.3. Try running "composer require symfony/mime".', __METHOD__), E_USER_DEPRECATED);
$mimeTypeGuesser = MimeTypeGuesser::getInstance();
}
} elseif (!$mimeTypeGuesser instanceof MimeTypes) {
@ -156,7 +156,9 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
if ($this->mimeTypeGuesser instanceof DeprecatedMimeTypeGuesserInterface && $mimeType = $this->mimeTypeGuesser->guess($object->getPathname())) {
return $mimeType;
} elseif ($this->mimeTypeGuesser && $mimeType = $this->mimeTypeGuesser->guessMimeType($object->getPathname())) {
}
if ($this->mimeTypeGuesser && $mimeType = $this->mimeTypeGuesser->guessMimeType($object->getPathname())) {
return $mimeType;
}

View File

@ -45,7 +45,7 @@
"symfony/yaml": "For using the default YAML mapping loader.",
"symfony/config": "For using the XML mapping loader.",
"symfony/property-access": "For using the ObjectNormalizer.",
"symfony/http-foundation": "To use the DataUriNormalizer.",
"symfony/http-foundation": "For using a MIME type guesser within the DataUriNormalizer.",
"doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.",
"doctrine/cache": "For using the default cached annotation reader and metadata cache."
},

View File

@ -34,7 +34,7 @@
"symfony/cache": "^3.4|^4.0|^5.0",
"symfony/property-access": "^3.4|^4.0|^5.0",
"symfony/property-info": "^3.4|^4.0|^5.0",
"symfony/translation": "^5.0",
"symfony/translation": "^4.4",
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.0",
"egulias/email-validator": "^1.2.8|~2.0"