This PR was merged into the 4.4 branch.
Discussion
----------
[WebLink] Escape double quotes in attributes values
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
If the attribute value contains a double quote, the serialized value is invalid: `</foo>; rel="alternate"; title="foo " bar"`. Ideally we would use `addcslashes` but we can't because users that already pass escaped values would then be impacted.
Commits
-------
7946be2b95 [WebLink] Escape double quotes in attributes values
This PR was submitted for the 5.2 branch but it was squashed and merged into the 4.4 branch instead.
Discussion
----------
[Console] fix QuestionHelper::getHiddenResponse() not working with space in project directory name
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#40190 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
Fixes#40190 to allow spaces in project directory name.
Commits
-------
0e421004eb [Console] fix QuestionHelper::getHiddenResponse() not working with space in project directory name
This PR was squashed before being merged into the 5.2 branch.
Discussion
----------
[String] Check if function exists before declaring it
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
If you installed a command line tool like `psalm` with composer and then try to run it on a project that included the String component you will get an error like:
> Fatal error: Cannot redeclare Symfony\Component\String\u() (previously declared in /Workspace/symfony/src/Symfony/Component/String/Resources/functions.php:14) in /user/.composer/vendor/symfony/string/Resources/functions.php on line 14
That is because we are loading two installations of the string component.
Commits
-------
cc00e0eb78 [String] Check if function exists before declaring it
This PR was merged into the 5.3-dev branch.
Discussion
----------
[DependencyInjection] Add `#[Autoconfigure]` to help define autoconfiguration rules
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Being inspired by the discussion with @derrabus in #39776.
This PR allows declaring autoconfiguration rules using an attribute on classes/interfaces, eg:
`#[Autoconfigure(bind: ['$foo' => 'bar'], tags: [...], calls: [...])]`
This should typically be added on a base class/interface to tell *how* implementations of such a base type should be autoconfigured. The attribute is parsed when autoconfiguration is enabled, except when a definition has the `container.ignore_attributes` tag, which allows opting out from this behavior.
As usual, the corresponding rules are applied only to services that have autoconfiguration enabled.
In practice, this means that this enables auto-tagging of all implementations of this interface:
```php
#[Autoconfigure(tags: ['my_tag'])]
interface MyInterface {...}
```
Of course, all auto-configurable settings are handled (calls, bindings, etc.)
This PR adds another attribute: `#[AutoconfigureTag()]`.
It extends `#[Autoconfigure]` and allows for specifically defining tags to attach by autoconfiguration.
The name of the tag is optional and defaults to the name of the tagged type (typically the FQCN of an interface). This should ease with writing locators/iterators of tagged services.
```php
#[AutoconfigureTag()]
interface MyInterface {...}
```
Commits
-------
64ab6a2850 [DependencyInjection] Add `#[Autoconfigure]` to help define autoconfiguration rules
* 5.2:
Ignore indirect deprecation triggered by doctrine/orm
Symfony Armenian Translations
[Translation] Allow using dashes in locale when linting Xliff files
use the right context for properties defined in traits
* 4.4:
Ignore indirect deprecation triggered by doctrine/orm
Symfony Armenian Translations
[Translation] Allow using dashes in locale when linting Xliff files
use the right context for properties defined in traits
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[Mailer] AWS SES transport Source ARN header support
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR | need help (this part was never mentioned in docs)
AWS SES API has [FromEmailAddressIdentityArn](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_SendEmail.html#SES-SendEmail-request-FromEmailAddressIdentityArn) field which is necessary for using identities verified by different AWS account.
With this PR I am adding ability to set this field via setting `X-SES-SOURCE-ARN` header.
I've added support for this API field in the same way as it was done before for `X-SES-CONFIGURATION-SET`. It was never documented, but you can use header `X-SES-CONFIGURATION-SET` to set `ConfigurationSetName` API param.
Commits
-------
d7225db7d5 [Mailer] AWS SES transport Source ARN header support
This PR was submitted for the 5.x branch but it was squashed and merged into the 4.4 branch instead.
Discussion
----------
Symfony Armenian Translations
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fix#38724
| License | MIT
| Doc PR | -
Commits
-------
93fe4a213e Symfony Armenian Translations
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Framework] Add tag assets.package to register asset packages
Replaces #38366
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | symfony/symfony-docs#14962
To configure asset packages in an application, we have to declare it in the `framework` configuration ([doc for assets config](https://symfony.com/doc/current/reference/configuration/framework.html#assets)). In some case we cannot use this configuration:
- To use a custom class as package
- To register an asset package in a shared bundle (my use-case).
This PR adds the `assets.package` tag. This tag is use to collect and inject package services into the `assets.packages` service, that is the registry for all packages. Since every package needs a name, the `package` attribute of the tag is used (same naming convention that the `console.command` tag).
Main changes:
- the packages defined in the `framework.assets` configuration are injected into the `assets.packages` using the tag instead of being directly injected in service declaration.
- changed signature of `Symfony\Components\Assets\Packages` constructor to accept an iterator (backward compatible).
- a new alias `assets._default_package` is defined even if assets are not configured.
### Example in `symfony/demo` ([commit](e5e5a8fff0...GromNaN:assets-package-tag)):
In `config/services.yaml`:
```yaml
avatar.strategy:
class: Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy
arguments:
- '%kernel.project_dir%/public/build/manifest.json'
avatar.package:
class: Symfony\Component\Asset\Package
arguments:
- '@avatar.strategy'
- '@assets.context'
tags:
- { name: assets.package, package: avatars }
```
Then we can use the package anywhere
```twig
<img src="{{ asset('anna.jpg', 'avatars') }}">
```
### Alternative using autoconfiguration with a custom class:
With a custom class implementing the `PackageInterface`, the package name can be provided by a the static method `getDefaultPackageName`. Autowiring and autoconfiguration will import the package.
```php
namespace App\Asset;
use Symfony\Component\Asset\PackageInterface;
class AvatarPackage implements PackageInterface
{
public static function getDefaultPackageName(): string
{
return 'avatars';
}
// ... Implements the interface
}
```
Commits
-------
6217ff7b6f [Asset] Add tag assets.package to register asset packages
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[Serializer] Allow to provide (de)normalization context in mapping
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#39039 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | TODO <!-- required for new features -->
As explained in the linked feature request, this brings the ability to configure context on a per-property basis, using Serializer mapping.
Considering:
```php
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
class Foo
{
/**
* @Serializer\Context({ DateTimeNormalizer::FORMAT_KEY = 'Y-m-d' })
*/
public \DateTime $date;
public \DateTime $anotherDate;
}
```
`$date` will be formatted with a specific format, while `$anotherDate` will use the default configured one (or the one provided in the context while calling `->serialize()` / `->normalize()`).
It can also differentiate normalization and denormalization contexts:
```php
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
class Foo
{
/**
* @Serializer\Context(
* normalizationContext = { DateTimeNormalizer::FORMAT_KEY = 'Y-m-d' },
* denormalizationContext = { DateTimeNormalizer::FORMAT_KEY = \DateTime::COOKIE },
* )
*/
public \DateTime $date;
}
```
As well as act differently depending on groups:
```php
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
class Foo
{
/**
* @Serializer\Groups({ "extended" })
* @Serializer\Context({ DateTimeNormalizer::FORMAT_KEY = \DateTime::RFC3339 })
* @Serializer\Context(
* context = { DateTimeNormalizer::FORMAT_KEY = \DateTime::RFC3339_EXTENDED },
* groups = {"extended"},
* )
*/
public \DateTime $date;
}
```
The annotation can be repeated as much as you want to handle the different cases.
Context without groups is always applied first, then context for groups are merged in the provided order.
Context provided when calling `->serialize()` / `->normalize()` acts as the defaults for the properties without context provided in the metadata.
XML mapping (see tests) is a lot verbose due to the required structure to handle groups.
Such metadata contexts are also forwarded to name converters, max depth handlers, callbacks, ...
Of course, PHP 8 attributes are also supported:
```php
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
class Foo
{
#[Serializer\Groups(["extended"])]
#[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => \DateTime::RFC3339])]
#[Serializer\Context(
context: [DateTimeNormalizer::FORMAT_KEY => \DateTime::RFC3339_EXTENDED],
groups: ["extended"],
)]
public \DateTime $date;
}
```
The PR should be ready for first batch of reviews / discussions.
- [x] Make Fabbot happy in 5.2
- [x] Missing `@Context` unit tests
- [x] rework xml & phpize values
- [x] Fix lowest build issue with annotations => bumped doctrine annotations to 1.7, as for other components
Commits
-------
7229fa1d8f [Serializer] Allow to provide (de)normalization context in mapping
This PR was merged into the 4.4 branch.
Discussion
----------
[PropertyInfo] use the right context for properties defined in traits
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#28732, #34191
| License | MIT
| Doc PR |
Commits
-------
1572491a8a use the right context for properties defined in traits
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[Translation] Allow using dashes in locale when linting Xliff files
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | fixes#40170
| License | MIT
| Doc PR | n/a
This pull request
* [x] asserts that the `XliffLintCommand` succeeds linting an Xliff file where both the the target language and the locale in the file name use dashes as separators
* [x] adjusts the `XliffLintCommand` to allow using the same value for target language and locale in the corresponding file name
Commits
-------
d106aa3f2d [Translation] Allow using dashes in locale when linting Xliff files
* 5.2:
[Workflow] Re-add InvalidTokenConfigurationException for BC
Fix PHP 8.1 null values
[Console] Fix PHP 8.1 null error for preg_match flag
Fix: Article
Definition::removeMethodCall should remove all matching calls
[HttpFoundation] Fix typo in exception message
mark the LazyIterator class as internal
fix extracting mixed type-hinted property types
[Worflow] Fixed GuardListener when using the new Security system
keep valid submitted choices when additional choices are submitted
* 4.4:
Fix PHP 8.1 null values
[Console] Fix PHP 8.1 null error for preg_match flag
Fix: Article
Definition::removeMethodCall should remove all matching calls
mark the LazyIterator class as internal
fix extracting mixed type-hinted property types
keep valid submitted choices when additional choices are submitted
This PR was merged into the 5.2 branch.
Discussion
----------
[Workflow] Re-add InvalidTokenConfigurationException for BC
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Reverts the BC breaking part of #39671
Commits
-------
b596568db9 [Workflow] Re-add InvalidTokenConfigurationException for BC
This PR was merged into the 5.2 branch.
Discussion
----------
[Worflow] Fixed GuardListener when using the new Security system
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#39505
| License | MIT
| Doc PR |
Commits
-------
bd26a79461 [Worflow] Fixed GuardListener when using the new Security system
This PR was merged into the 4.4 branch.
Discussion
----------
Fix: Article
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | n/a
| License | MIT
| Doc PR | n/a
This pull request
* [x] fixes usages of the indefinite article `a` where `an` should be used instead
Commits
-------
34b320ba97 Fix: Article
This PR was merged into the 4.4 branch.
Discussion
----------
[Console] Fix PHP 8.1 null error for preg_match flag
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Since PHP 8.1, `null` is no longer accepted as `$flags` in `preg_match`, default integer `0` value should be used instead.
Commits
-------
52f02e529a [Console] Fix PHP 8.1 null error for preg_match flag
This PR was merged into the 5.3-dev branch.
Discussion
----------
Fix package name
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- Never break backward compatibility (see https://symfony.com/bc).
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too.)
- Features and deprecations must be submitted against branch 5.x.
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
-->
Fix Package name as the Bridge is named `SpotHit` and not `Spothit`.
Commits
-------
5f8c736303 Fix package name
This PR was merged into the 5.3-dev branch.
Discussion
----------
[PasswordHasher] Fix: Use algorithm instead of algo
| Q | A
| ------------- | ---
| Branch? | 5.5
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | n/a
| License | MIT
| Doc PR | n/a
This pull request
* [x] renames fields, variables, and parameters using `algos` or `algo` (which appear to be entirely made-up words) to `algorithms` and `algorithm` respectively
Commits
-------
a4dd14b478 Fix: Use algorithm instead of algo
This PR was merged into the 5.3-dev branch.
Discussion
----------
[PasswordHasher] Fix: Run 'php-cs-fixer fix'
| Q | A
| ------------- | ---
| Branch? | 5.5
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | n/a
| License | MIT
| Doc PR | n/a
This pull request
* [x] runs `php-cs-fixer fix` in `src/Symfony/Component/PasswordHasher`
💁♂️ I do not know who or what enforces coding standard issues in this repository, but after opening a few pull requests in this repository, I noticed that `fabbot.io` repeatedly reports coding standard violations that are unrelated to the proposed changes. As an experiment I ran
```
$ php-cs-fixer fix
```
on the entire repository and found a lot of issues. Not sure, would you not prefer to have these fixed?
Since the `PasswordHasher` component was only recently extracted, I assume it is safe to propose to run `php-cs-fixer fix` at least on this newly introduced component.
Commits
-------
2102170e43 Fix: Run 'php-cs-fixer fix'
This PR was submitted for the 5.x branch but it was merged into the 4.4 branch instead.
Discussion
----------
[DependencyInjection] Definition::removeMethodCall should remove all matching calls
It would only remove the first match, leaving the other method call(s) there to exist. This leads to unexpected situations.
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | None
| License | MIT
| Doc PR |
I found out that `Definition::removeMethodCall` only removes the first method call and stops. It should remove all method calls named `$method`.
Commits
-------
944ba23b58 Definition::removeMethodCall should remove all matching calls