This PR was merged into the 5.2-dev branch.
Discussion
----------
[FrameworkBundle] Add days before expiration in "about" command
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes (with RFC)
| Deprecations? | no
| Tickets | Slack discussion + see RFC below
| License | MIT
| Doc PR |
Maybe this can be usefull in the `bin/console about` output.
Following a small discussion on Slack
<details>
<summary>See discussion </summary>
<img width="910" alt="sf_slack" src="https://user-images.githubusercontent.com/13205768/89516646-029dea00-d7d9-11ea-8ff5-eed5ae72fc77.png">
</details>
---
Symfony 5.1 output:
<img width="681" alt="sf51" src="https://user-images.githubusercontent.com/13205768/89515902-067d3c80-d7d8-11ea-8676-1f90dd0a3418.png">
---
Symfony 5.foo_bar output:
With:
```php
// symfony/http-kernel/Kernel.php
const END_OF_MAINTENANCE = '08/2020'; // this month
const END_OF_LIFE = '09/2020'; // next month
```
<img width="680" alt="sf51_fake" src="https://user-images.githubusercontent.com/13205768/89516056-375d7180-d7d8-11ea-9345-83db200a693d.png">
---
## RFC
Is there a way in Symfony land packages to have such info or/and in Composer in general? the EOL of a package version.
Like for example the https://github.com/FriendsOfPHP/security-advisories `Security Advisories` feature,
but for `End Of Life Advisories` where packages maintainers can add their packages, and this data can be read by `composer` or an other command
~Or maybe directly inside the `composer.json`, like an `"eol": "true"` // and `false` by default if not defined~ (not possible)
Thanks
Commits
-------
0b0a1f6f8e Add days before expiration in "about" command
This PR was merged into the 5.2-dev branch.
Discussion
----------
[PhpUnitBridge] Fix assertDoesNotMatchRegularExpression() polyfill
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | N/A
| License | MIT
| Doc PR | N/A
The `assertDoesNotMatchRegularExpression()` polyfill currently does not work because the `$pattern` argument is not passed down correctly.
Commits
-------
cdd727a93b [PhpUnitBridge] Fix assertDoesNotMatchRegularExpression() polyfill.
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[Notifier] Change notifier recipient handling
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#35558 <!-- prefix each issue number with "Fix #", if any -->
| License | MIT
| Doc PR | tbd.
According to @wouterj's reasoning in #35558 I did the following to merge the `AdminRecipient` with the `Recipient` class:
- introduced a `EmailRecipientInterface` with `getEmail(): string` methods
- introduced a `RecipientInterface` that is extended by `EmailRecipientInterface` and `SmsRecipientInterface`
- changed `Recipient` class which now holds an email and a phone number property and implements the `EmailRecipientInterface` and the `SmsRecipientInterface`
- changed `NoRecipient` class which now implements the `RecipientInterface`
- removed the `AdminRecipient` and fixed all related type-hints
- introduced an `EmailRecipient` and `SmsRecipient`
- changed the type-hint of the `$recipient` argument in `NotifierInterface::send()`, `Notifier::getChannels()`, `ChannelInterface::notifiy()` and `ChannelInterface::supports()` to `RecipientInterface`
- changed the type hint of the `$recipient` argument in the `as*Message()` of the `EmailNotificationInterface` and `SmsNotificationInterface` which now uses the introduced interfaces
- changed the type hint of the `$recipient` argument in the static `fromNotification()` factory methods in `EmailMessage` and `SmsMessage` which now uses the introduced interfaces
- changed `EmailChannel` to only support recipients which implement the `EmailRecipientInterface`
- changed `SmsChannel` only supports recipients which implement the `SmsRecipientInterface`
Commits
-------
588607bdd1 [Notifier] Change notifier recipient handling
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[Notifier] Add Google Chat bridge
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | Fix#35875
| License | MIT
| Doc PR | symfony/symfony-docs#14018
Uses the webhook to send messages.
```php
$transport = (new GoogleChatTransportFactory())
->create(Dsn::fromString('googlechat://<key>:<token>@default/<space>?threadKey=<thread>'));
```
The `threadKey` can be any string, it allows to post all messages to the same thread instead of creating a new thread for each message.
Example of notification for exceptions:
![image](https://user-images.githubusercontent.com/400034/79625049-7a5ee080-8126-11ea-9216-588309642bd3.png)
Commits
-------
c4cda758b5 [Notifier] Add Google Chat bridge
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Lock] downgrade log.info to log.debug
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| Deprecations? | ni
| Tickets | /
| License | MIT
| Doc PR | /
This PR follows #37713 and reduce log verbosity in CombinedStore
Commits
-------
080f1149a1 Reduce log verbosity for CombinedStore
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[HttpClient] add EventSourceHttpClient to consume Server-Sent Events
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | na
| License | MIT
| Doc PR | symfony/symfony-docs#...
<details>
<summary>First implementation</summary>
This patch implements the [w3c Server-Sent Events specification](https://www.w3.org/TR/eventsource/#eventsource) on top of symfony's http client. It provides an `EventSource` class that allows you to interact of server sent events.
Comparing to the Javascript implementation, we won't be able to use the same API. Indeed, in php listeners need to be setup before we connect to the HTTP stream.
I'm not fond of adding a dependency to EventDispatcher from HTTP Client, therefore I'm all ears if you have better solutions.
About event parsing, I wanted to avoid using regular expression and it uses smart data split. Note that I had to concatenate an internal buffer and only handle the data when a newline is found to cover long chunks. This is an alternative to this [react php eventsource](https://github.com/clue/reactphp-eventsource). Note that this implementation is closer to the specification in some cases that are still to be covered by tests (`retry`, `data:value` without space after colon is valid etc.).
</details>
This is an implementation of the [Server-Sent Events specification](https://html.spec.whatwg.org/multipage/server-sent-events.html) based on symfony's HTTP Client. After a few suggestions on the first implementation (see details above), I've implemented a chunk generator with this kind of API:
```php
$client = new EventSourceHttpClient($client, 10);
$source = $client->connect('GET', "http://localhost:8080/events");
while($source) {
foreach ($client->stream($source, 2) as $r => $chunk) {
if ($chunk->isTimeout()) {
dump([
'timeout' => [
'retry' => 1 + count($r->getInfo('previous_info') ?? [])
],
]);
continue;
}
if ($chunk->isLast()) {
dump([
'eof' => [
'retries' => count($r->getInfo('previous_info') ?? [])
],
]);
$source = null;
return;
}
dump($chunk);
}
}
```
TODO:
- [x] validate implementation (~~don't use EventDispatcher ?~~, need to be implemented as `stream` instead of `message`)
- [x] default timeout value
- [x] implement retry/reconnection
- [x] tests (do test with super long chunk, retry, bad http content-type response)
- [ ] update changelog
- [ ] document
Commits
-------
12ccca3cd4 [HttpClient] add EventSourceHttpClient to consume Server-Sent Events
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Notifier] Add Zulip notifier bridge
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | See #33687
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/pull/13604
This adds a [Zulip](https://zulipchat.com/) (another popular open source Slack alternative) transport for the new Notifier component.
#### Sample DSN
```ZULIP_DSN=zulip://test-bot@zulipchat.com:api-key@example.zulipchat.com?channel=builds```
#### Configuration
```yml
# config/packages/notifier.yaml
framework:
notifier:
chatter_transports:
zulip: '%env(ZULIP_DSN)%'
```
#### Example
```php
public function index(ChatterInterface $chatter)
{
$message = (new ChatMessage('New order arrived!', new ZulipOptions('Ordering')))
->transport('zulip');
$chatter->send($message);
...
}
```
Commits
-------
bd4fd32121 Adds Zulip notifier bridge
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Notifier] Fix SentMessage implementation
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | n/a
#36611 broke the Notifier when used with Messenger.
/cc @jeremyFreeAgent
Commits
-------
92c28de41b [Notifier] Fix SentMessage implementation
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Notifier] Make Freemobile config more flexible
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | n/a<!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | n/a
As Freemobile only supports French phone numbers, let's support French numbers without the international code.
Commits
-------
4dfde6ae7c [Notifier] Make Freemobile config more flexible
* 5.1:
fail properly when the required service is not defined
Fix typo
[Finder] Fix GitIgnore parser when dealing with (sub)directories and take order of lines into account
Update UPGRADE-5.0.md
Added the missing reset tag to mailer.logger_message_listener
Fix invalid option sslmode
Updated README for the Mailer component
fix error with custom function and web profiler routing tab
* 4.4:
fail properly when the required service is not defined
Fix typo
[Finder] Fix GitIgnore parser when dealing with (sub)directories and take order of lines into account
Update UPGRADE-5.0.md
Added the missing reset tag to mailer.logger_message_listener
Updated README for the Mailer component
fix error with custom function and web profiler routing tab
This PR was merged into the 4.4 branch.
Discussion
----------
[FrameworkBundle] fail properly when the required service is not defined
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
Before:
```
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "mailer.logger_message_listener".
```
After:
```
A client must have Mailer enabled to make email assertions. Did you forget to require symfony/mailer?
```
Commits
-------
a16ebc177d fail properly when the required service is not defined
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Security] class Security implements AuthorizationCheckerInterface
The class has the method of AuthorizationCheckerInterface already.
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| 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 | <!-- required for new features -->
The class Security has the method for interface AuthorizationCheckerInterface already. By implementing the interface, Security can be passed to methods typehinted with AuthorizationCheckerInterface.
Commits
-------
cea6ebda5b [Security] class Security implements AuthorizationCheckerInterface
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[Messenger] add redeliveredAt in RedeliveryStamp construct
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
---
this would allows one to correctly unserialize a RedeliveryStamp with a custom serializer not using the php serialize function
Commits
-------
64d26836da [Messenger] add redeliveredAt in RedeliveryStamp construct
This PR was merged into the 5.2-dev branch.
Discussion
----------
[EventDispatcher] Minor: Avoid not needed null check in dispatch()
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| License | MIT
| Doc PR | -
Just found a not needed null check in the heavyly called EventDispatcher::dispatch() method - the $eventName get's always a string now - no null anymore, as it gets the class name instead.
Commits
-------
0d36c11f28 [EventDispatcher] Avoid not needed null check in dispatch()
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Validator] Add Isin validator constraint
Co-Authored-By: Yannis Foucher <33806646+YaFou@users.noreply.github.com>
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | Fix#36362
| License | MIT
| Doc PR | symfony/symfony-docs#13960
Rebase of https://github.com/symfony/symfony/pull/36368
I asked him by mail and he didn't have time to finish the PR and allowed me to do it.
Commits
-------
8e1ffc8b99 Feature #36362 add Isin validator constraint
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[Mailer] Prevent MessageLoggerListener from leaking in env=prod
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | yes
| License | MIT
I was trying to send a batch of emails with `--env=prod` when I noticed that `MessageLoggerListener` was still collecting all the messages and leaking the memory. I tried to do `$this->getApplication()->reset()`, but it didn't work because `MessageLoggerListener` was not tagged (now fixed in #37705).
In this PR I propose to move the declaration of `MessageLoggerListener` to `mailer_debug.php` since the only service depending on it is `mailer.data_collector` from `mailer_debug.php`. If a developer needs to collect sent emails, a custom listener could be implemented on the project side.
- [x] deprecate the service
- [x] add a new one to `mailer_debug.php`
- [ ] add a line to CHANGELOG.md
- [ ] add a line to UPGRADE-5.2.md
Commits
-------
e226775d97 [Mailer] Prevent MessageLoggerListener from leaking in env=prod
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[Lock] downgrade log.info to log.debug
| Q | A
| ------------- | ---
| Branch? | master for features / 3.4, 4.4 or 5.1 for bug fixes <!-- see below -->
| Bug fix? | yes/no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#37710
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
we changed log behavior see issue for more details
<!--
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 master.
-->
Commits
-------
eea41d9655 [Lock] downgrade log.info to log.debug
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Console] Add signal event
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no
| Tickets | Fix#33411
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
This new feature allows to set a listener for performing some actions after the console command get a signal.
Usage:
```php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleSignalEvent;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\SignalRegistry\SignalRegistry;
use Symfony\Component\Console\Command\Command;
class HelloWorldCommand extends Command {
protected static $defaultName = 'app:hello-world';
protected function execute(InputInterface $input, OutputInterface $output) {}
}
$application = new Application();
$dispatcher = new EventDispatcher();
// Function that will handle signals
$dispatcher->addListener(ConsoleEvents::SIGNAL, function (ConsoleSignalEvent $event) {
echo 'Handled signal #' . $event->getHandlingSignal() . PHP_EOL;
});
$application->setDispatcher($dispatcher);
$application->setSignalRegistry(new SignalRegistry());
// List of POSIX signals for handling
$application->addHandlingSignals(SIGINT, SIGUSR1);
$application->add(new HelloWorldCommand());
$application->run();
```
Commits
-------
859b692240 [Console] add console.signal event
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Validator] Added support for cascade validation on typed properties
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | ~
| License | MIT
| Doc PR | TODO
This PR leverages PHP 7.4 property types to "guess" typed object members and enable default cascade validation on nested objects.
Before:
```php
use Symfony\Component\Validator\Constraints as Assert;
class Composite
{
/**
* @var self[]
*
* @Assert\Valid
*/
public array $children;
/**
* @Assert\Valid
*/
public ?self $parent;
/**
* @Assert\Valid
*/
public static ?self $root;
}
```
After:
```php
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Assert\Cascade
*/
class Composite
{
/*
* @var self[]
*/
public array $children;
public ?self $parent;
public static ?self $root;
}
```
The constraint can also be used in xml, yaml, and of course raw PHP.
___________
Question: is the naming ok, maybe we could use `CascadeValid` to be more explicit?
Commits
-------
f4679ef08a [Validator] Added support for cascade validation on typed properties
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[DependencyInjection] Resolve parameters in tag arguments
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | Fix#35337
| License | MIT
| Doc PR | None, yet, will follow if this is accepted
Arguably this could be a BC break if people are actively relying on parameters not being resolved in tag parameters, although I can't come up with a sensible use case for that scenario.
Commits
-------
3dba1fe7bf [DependencyInjection] Resolve parameters in tag arguments
This PR was merged into the 5.2-dev branch.
Discussion
----------
[Console] added info method to symfony style
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
It would be nice to have an info method as part of the SymfonyStyle class. This would prevent having to use the \<INFO\> tag, and it is consistent with other methods like warning and error (similar to the types available in monolog)
Commits
-------
4cf1a1e8e6 fixed docblock
204cd739d3 added info method to symfony style
This PR was merged into the 5.2-dev branch.
Discussion
----------
[FrameworkBundle] Deprecate some public services to private
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| Deprecations? | yes
| Tickets | -
| License | MIT
| Doc PR | -
Now that we can deprecate public services to private, here is a first pass on the FWB. I think all those services don't need to be public, ie we never need to access them directly in Symfony's code (except in some tests that I had to modify accordingly). I think most of theses services needed to be public before we hooked the AbstractController with a service subscriber. There are definitely more of them that can be deprecated (ie: created workflows and state machines are public but don't need to be ?) but let's start with the easy ones.
Commits
-------
87868baacb [FrameworkBundle] Deprecate some public services to private
This PR was merged into the 5.2-dev branch.
Discussion
----------
Added a FrenchInflector for the String component
I read in [this blog post](https://symfony.com/blog/new-in-symfony-5-1-deprecated-the-inflector-component) this sentence
> Symfony Inflector component converts words between their singular and plural forms (**for now, only in English**)
So I created a FrenchInflector class implementing the InflectorInterface from the String component. This inflector uses regular expressions and it is tested in the FrenchInflectorTest with a lot of the french exceptions.
| Q | A
| ------------- | ---
| Branch | master
| Bug fix | no
| New feature | yes
| Deprecations | no
| License | MIT
| Doc PR | Not yet
Changelog has been updated, but I'm not sure I did it in the good paragraph.
I don't know if I should update the symfony/symfony-docs, but I have created an example and I could create a PR with it, if you want.
```php
<?php
use Symfony\Component\String\Inflector\FrenchInflector;
$inflector = new FrenchInflector();
$result = $inflector->singularize('dents'); // ['dent']
$result = $inflector->singularize('souris'); // ['souris']
$result = $inflector->singularize('messieurs'); // ['monsieur']
$result = $inflector->pluralize('cinquante'); // ['cinquante']
$result = $inflector->pluralize('pou'); // ['poux']
$result = $inflector->pluralize('cheval'); // ['chevaux']
```
**fabbot.io** is detecting a typo, but this is not. The patch done by fabpot suggests to replace the french 'embarras' word by 'embarrass'. I shall not remove or replace it, because "embarras" is an invariant word.
Commits
-------
d903d9a757 Added a FrenchInflector for the String component French inflector implements InflectorInterface, it uses regexp and it is tested in the FrenchInflectorTest