* 7.4:
[FrameworkBundle] Dump all registered extensions’ configuration reference
fix merge
Mark FormFlow as finished if the last step is skipped
[HttpKernel] Fix using MapRequestPayload on nullable arguments
[ObjectMapper] bypass lazy ghost with class transform
[WebProfilerBundle] fix displaying runner
[DependencyInjection] Fix preloading LazyClosure
[Emoji] Update list to version 17
make doLoadClassMetadata() methods private
fix routing config type information
[HttpClient] Don't reset unused clients in data collector
* 7.4:
deprecate passing an associative array to GroupSequence
[Uid] Add `MockUuidFactory` for deterministic UUID generation in tests
deprecate extending RememberMeDetails using legacy constructor signature
[Notifier][LOX24] Add Lox24 webhook request parser support
[WebProfilerBundle] Upgrade mermaid to v11.12.0
[MonologBridge] Deprecate `NotFoundActivationStrategy`
Simplify ConsoleFormatterTest
deprecate implicit constraint option names in YAML/XML mapping files
[Security] Fix preload warning in `AuthorizationChecker`
[Notifier] Add support for building SmsEvent by dlr_code and RemoteEvent for other LOX24 webhook event types
allow protocols to be passed as a string
Fix merge
fix high deps tests
* 7.4:
[SecurityBundle] Fix semantic configuration for singulars/plurals in XML
[JsonPath] Make the component RFC compliant
[Security] Add `$tokenSource` argument to `#[IsCsrfTokenValid]` to support reading tokens from the query string or headers
[Config] Fix generics on TreeBuilder and ArrayNodeDefinition
Fix `#[IsCsrfTokenValid]` to ensure `$tokenKey` is non-nullable
[Security] Deprecate `PersistentToken::getClass()` and `RememberMeDetails::getUserFqcn()` in order to remove the user FQCN from the remember-me cookie in 8.0
[Serializer] Add `#[ExtendsSerializationFor]` to declare new serialization attributes for a class
[Validator] Add `#[ExtendsValidationFor]` to declare new constraints for a class
[WebProfilerBundle] Show `EventStream`s in debug toolbar
This PR was merged into the 7.4 branch.
Discussion
----------
[Validator] Add `#[ExtendsValidationFor]` to declare new constraints for a class
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues | -
| License | MIT
This PR builds on #61528
I propose to add a `#[ExtendsValidationFor]` attribute that allows adding validation constraints to another class.
This is typically needed for third party classes. For context, Sylius has a nice doc about this:
https://docs.sylius.com/the-customization-guide/customizing-validation
At the moment, the only way to achieve this is by declaring the new constraints in the (hardcoded) `config/validation/` folder, using either xml or yaml. No attributes.
With this PR, one will be able to define those extra constraints using PHP attributes, set on classes that'd mirror the properties/getters of the targeted class. The compiler pass will ensure that all properties/getters declared in these source classes also exist in the target class. (source = the app's class that declares the new constraints; target = the existing class to add constraints to.)
```php
#[ExtendsValidationFor(TargetClass::class)]
abstract class SourceClass
{
#[Assert\NotBlank(groups: ['my_app'])]
#[Assert\Length(min: 3, groups: ['my_app'])]
public string $name = '';
#[Assert\Email(groups: ['my_app'])]
public string $email = '';
#[Assert\Range(min: 18, groups: ['my_app'])]
public int $age = 0;
}
```
(I made the class abstract because it's not supposed to be instantiated - but it's not mandatory.)
Here are the basics of how this works:
1. During container compilation, classes marked with `#[ExtendsValidationFor(Target::class)]` are collected and validated: the container checks that members declared on the source exist on the target. If not, a `MappingException` is thrown.
2. The validator is configured to map the target to its source classes.
3. At runtime, when loading validation metadata for the target, attributes (constraints, callbacks, group providers) are read from both the target and its mapped source classes and applied accordingly.
Commits
-------
e884a769a70 [Validator] Add `#[ExtendsValidationFor]` to declare new constraints for a class
* 7.4:
[Serializer] Allow using attributes to declare compile-time serialization metadata
[Validator] Allow using attributes to declare compile-time constraint metadata
[DoctrineBridge] Use a single table in isSameDatabaseChecker
[DependencyInjection] Minor optims
* 7.4:
[Validator][Serializer] Make internal properties private
[VarExporter] Fix serializing classes with __serialize() returning unprefixed private properties
Remove direct access to internal properties cross-components
remove deprecated nullable option from primary key columns
[Validator] Optimize serialized metadata and cleanup tests
specific fix to avoid 'outag' when inflecting 'outages'
Use <info> for options in command description
[ObjectMapper] Remove obsolete TODO
[HttpFoundation][HttpKernel][WebProfilerBundle] Add support for the `QUERY` HTTP method
[DependencyInjection] Don’t autowire excluded services
Add bool return type to CustomCredentials callable parameter
[Process] Enhance hasSystemCallBeenInterrupted function for non-english locale
[FrameworkBundle] Make `cache:warmup` warm up read-only caches
* 7.4:
[Mime] Deprecate implementing `__sleep/wakeup()` on `AbstractPart` implementations
[Validator] Deprecate implementing `__sleep/wakeup()` on GenericMetadata implementations
[String] Deprecate implementing `__sleep/wakeup()` on string implementations
More cleanups related to internal sleep/wakeup usages
[HttpKernel] Deprecate `__sleep/wakeup()` on kernels and data collectors and make `Profile` final
[Serializer] Make `AttributeMetadata` and `ClassMetadata` final
Replace __sleep/wakeup() by __(un)serialize() when BC isn't a concern
chore: PHP CS Fixer - simplify config
* 7.4:
run tests using PHPUnit 11.5
make data provider static
[Lock] Fix using fractional TTLs on all platforms
[Lock] Fixes an issue with PostgreSQL when using fractional TTLs
[Console][Table] Fix unnecessary wrapping
[DependencyInjection] Deprecate registering a service without a class when its id is a non-existing FQCN
disable detecting modified indexes with DBAL 4.3
[cache] RedisTrait::doFetch should use pipeline instead of mget for Relay\Cluster
relax assertions for forward compatibility with Symfony 7.4
[Console][Table] Fix invalid UTF-8 due to text wrapping
This PR was merged into the 7.1 branch.
Discussion
----------
[Serializer][Validator] prevent failures around not existing TypeInfo classes
| Q | A
| ------------- | ---
| Branch? | 7.1
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues |
| License | MIT
Having a `getType()` method on an extractor is not enough. Such a method may exist to be forward-compatible with the TypeInfo component. We still must not call it if the TypeInfo component is not installed to prevent running into errors for not-defined classes when the TypeInfo component is not installed.
Commits
-------
386453ee77b prevent failures around not existing TypeInfo classes
Having a getType() method on an extractor is not enough. Such a method may
exist to be forward-compatible with the TypeInfo component. We still must
not call it if the TypeInfo component is not installed to prevent running into
errors for not-defined classes when the TypeInfo component is not installed.
* 7.1:
fix merge
[AssetMapper] Split test dirs in tests
Fix typo
Change incorrect check for the `stateless` request attribute
[Validator] add setGroupProvider to AttributeLoader
use copy() instead of rename() on Windows
test: kebab-case to snake_case
[PropertyInfo] Handle collection in PhpStan same as PhpDoc
[Messenger] Passing to `WorkerMessageRetriedEvent` envelope with actual stamps after sent
* 7.0:
fix merge
[AssetMapper] Split test dirs in tests
Fix typo
Change incorrect check for the `stateless` request attribute
[Validator] add setGroupProvider to AttributeLoader
use copy() instead of rename() on Windows
test: kebab-case to snake_case
[PropertyInfo] Handle collection in PhpStan same as PhpDoc
[Messenger] Passing to `WorkerMessageRetriedEvent` envelope with actual stamps after sent
* 7.0:
fix compatibility with Twig 3.10
[Strings][EnglishInflector] Fix incorrect pluralisation of 'Album'
handle union and intersection types for cascaded validations
move wiring of the property info extractor to the ObjectNormalizer
restore deprecated properties
move Process component dep to require-dev
Remove calls to `onConsecutiveCalls()`
fix: remove unwanted type cast
accept AbstractAsset instances when filtering schemas
better distinguish URL schemes and windows drive letters
handle edge cases when constructing constraints with named arguments
convert empty CSV header names into numeric keys
* 6.4:
fix compatibility with Twig 3.10
[Strings][EnglishInflector] Fix incorrect pluralisation of 'Album'
handle union and intersection types for cascaded validations
move wiring of the property info extractor to the ObjectNormalizer
restore deprecated properties
move Process component dep to require-dev
Remove calls to `onConsecutiveCalls()`
fix: remove unwanted type cast
accept AbstractAsset instances when filtering schemas
better distinguish URL schemes and windows drive letters
handle edge cases when constructing constraints with named arguments
convert empty CSV header names into numeric keys
* 5.4:
fix compatibility with Twig 3.10
[Strings][EnglishInflector] Fix incorrect pluralisation of 'Album'
handle union and intersection types for cascaded validations
move wiring of the property info extractor to the ObjectNormalizer
move Process component dep to require-dev
Remove calls to `onConsecutiveCalls()`
fix: remove unwanted type cast
accept AbstractAsset instances when filtering schemas
better distinguish URL schemes and windows drive letters
convert empty CSV header names into numeric keys
* 6.4:
Fix implicitly-required parameters
minor #53524 [Messenger] [AmazonSqs] Allow `async-aws/sqs` version 2 (smoench)
Fix bad merge
List CS fix in .git-blame-ignore-revs
Fix implicitly-required parameters
List CS fix in .git-blame-ignore-revs
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
[Messenger][AmazonSqs] Allow async-aws/sqs version 2