Merge branch '3.3' into 3.4

* 3.3:
  fix merge
  [Translation] Fix InvalidArgumentException when using untranslated plural forms from .po files
  Fixed exit code with non-integer throwable code
  Add suggestions
  Added instructions to upgrade Symfony applications to 4.x
This commit is contained in:
Nicolas Grekas 2017-12-12 09:27:14 +01:00
commit 6aa18bf6a8
8 changed files with 61 additions and 6 deletions

View File

@ -1,6 +1,40 @@
UPGRADE FROM 3.x to 4.0
=======================
Symfony Framework
-----------------
The first step to upgrade a Symfony 3.x application to 4.x is to update the
file and directory structure of your application:
| Symfony 3.x | Symfony 4.x
| ----------------------------------- | --------------------------------
| `app/config/` | `config/`
| `app/config/*.yml` | `config/*.yaml` and `config/packages/*.yaml`
| `app/config/parameters.yml.dist` | `config/services.yaml` and `.env.dist`
| `app/config/parameters.yml` | `config/services.yaml` and `.env`
| `app/Resources/<BundleName>/views/` | `templates/bundles/<BundleName>/`
| `app/Resources/` | `src/Resources/`
| `app/Resources/assets/` | `assets/`
| `app/Resources/translations/` | `translations/`
| `app/Resources/views/` | `templates/`
| `src/AppBundle/` | `src/`
| `var/logs/` | `var/log/`
| `web/` | `public/`
| `web/app.php` | `public/index.php`
| `web/app_dev.php` | `public/index.php`
Then, upgrade the contents of your console script and your front controller:
* `bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
* `public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php
Lastly, read the following article to add Symfony Flex to your application and
upgrade the configuration files: https://symfony.com/doc/current/setup/flex.html
If you use Symfony components instead of the whole framework, you can find below
the upgrading instructions for each individual bundle and component.
ClassLoader
-----------

View File

@ -32,7 +32,8 @@
"suggest": {
"symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.",
"symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings. You need version ~2.3 of the console for it.",
"symfony/event-dispatcher": "Needed when using log messages in console commands."
"symfony/event-dispatcher": "Needed when using log messages in console commands.",
"symfony/var-dumper": "For using the debugging handlers like the console handler or the log server handler."
},
"autoload": {
"psr-4": { "Symfony\\Bridge\\Monolog\\": "" },

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\WebServerBundle\Command;
use Monolog\Formatter\FormatterInterface;
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Command\Command;
@ -37,6 +38,11 @@ class ServerLogCommand extends Command
return false;
}
// based on a symfony/symfony package, it crashes due a missing FormatterInterface from monolog/monolog
if (!class_exists(FormatterInterface::class)) {
return false;
}
return parent::isEnabled();
}

View File

@ -29,6 +29,10 @@
"/Tests/"
]
},
"suggest": {
"symfony/monolog-bridge": "For using the log server.",
"symfony/expression-language": "For using the filter option of the log server."
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {

View File

@ -78,6 +78,6 @@ final class ConsoleErrorEvent extends ConsoleEvent
*/
public function getExitCode()
{
return null !== $this->exitCode ? $this->exitCode : ($this->error->getCode() ?: 1);
return null !== $this->exitCode ? $this->exitCode : (is_int($this->error->getCode()) ? $this->error->getCode() : 1);
}
}

View File

@ -33,7 +33,7 @@ array(1) {
[0]=>
string(37) "Error and exception handlers do match"
}
object(Symfony\Component\Debug\Exception\FatalErrorException)#4 (8) {
object(Symfony\Component\Debug\Exception\FatalErrorException)#%d (%d) {
["message":protected]=>
string(199) "Error: Class Symfony\Component\Debug\Broken contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize)"
%a

View File

@ -49,10 +49,16 @@ class MessageSelector
*/
public function choose($message, $number, $locale)
{
preg_match_all('/(?:\|\||[^\|])++/', $message, $parts);
$parts = array();
if (preg_match('/^\|++$/', $message)) {
$parts = explode('|', $message);
} elseif (preg_match_all('/(?:\|\||[^\|])++/', $message, $matches)) {
$parts = $matches[0];
}
$explicitRules = array();
$standardRules = array();
foreach ($parts[0] as $part) {
foreach ($parts as $part) {
$part = trim(str_replace('||', '|', $part));
if (preg_match('/^(?P<interval>'.Interval::getIntervalRegexp().')\s*(?P<message>.*?)$/xs', $part, $matches)) {
@ -76,7 +82,7 @@ class MessageSelector
if (!isset($standardRules[$position])) {
// when there's exactly one rule given, and that rule is a standard
// rule, use this rule
if (1 === count($parts[0]) && isset($standardRules[0])) {
if (1 === count($parts) && isset($standardRules[0])) {
return $standardRules[0];
}

View File

@ -128,6 +128,10 @@ class MessageSelectorTest extends TestCase
array("This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1),
// esacape pipe
array('This is a text with | in it. Selector = 0.', '{0}This is a text with || in it. Selector = 0.|{1}This is a text with || in it. Selector = 1.', 0),
// Empty plural set (2 plural forms) from a .PO file
array('', '|', 1),
// Empty plural set (3 plural forms) from a .PO file
array('', '||', 1),
);
}
}