8000 Merge branch '3.2' · symfony/symfony@428b9bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 428b9bf

Browse files
committed
Merge branch '3.2'
* 3.2: [Console] Do not duplicate Helper::strlen() code [FrameworkBundle] Adding the extension XML [Form] Minor: Fix comment in ChoiceType [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice fixed CS fixed CS [DI] Fix PhpDumper blank lines around namespace fixed CS [Workflow] fix use directives [Workflow] Move twig extension registration to twig bundle Filesystem: annotate the one network test with a "network" group. [DependencyInjection] Don't store default deprecation template in every service definition instance
2 parents ae9bda1 + 329e96c commit 428b9bf

File tree

20 files changed

+41
-38
lines changed

20 files changed

+41
-38
lines changed

src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Twig\Extension;
1313

1414
use Symfony\Component\Workflow\Registry;
15+
use Symfony\Component\Workflow\Transition;
1516

1617
/**
1718
* WorkflowExtension.

src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function initializeBundles()
117117
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
118118
// as this method is not called when the container is loaded from the cache.
119119
$container = $this->getContainerBuilder();
120-
$bundles = $this->getContainer()->get('kernel')->registerBundles();
120+
$bundles = $this->getContainer()->get('kernel')->getBundles();
121121
foreach ($bundles as $bundle) {
122122
if ($extension = $bundle->getContainerExtension()) {
123123
$container->registerExtension($extension);

src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" public="true" />
2727
<service id="Symfony\Component\Workflow\Registry" alias="workflow.registry" />
2828

29-
<service id="workflow.twig_extension" class="Symfony\Bridge\Twig\Extension\WorkflowExtension" public="true">
30-
<argument type="service" id="workflow.registry" />
31-
<tag name="twig.extension" />
32-
</service>
33-
3429
<service id="workflow.security.expression_language" class="Symfony\Component\Workflow\EventListener\ExpressionLanguage" />
3530
</services>
3631
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@
3232
array('%count%' => 10)
3333
) ?>
3434

35-
<?php echo $view['translator']->trans('other-domain-test-no-params-short-array', [], 'not_messages'); ?>
35+
<?php echo $view['translator']->trans('other-domain-test-no-params-short-array', array(), 'not_messages'); ?>
3636

3737
<?php echo $view['translator']->trans('other-domain-test-no-params-long-array', array(), 'not_messages'); ?>
3838

39-
<?php echo $view['translator']->trans('other-domain-test-params-short-array', ['foo' => 'bar'], 'not_messages'); ?>
39+
<?php echo $view['translator']->trans('other-domain-test-params-short-array', array('foo' => 'bar'), 'not_messages'); ?>
4040

4141
<?php echo $view['translator']->trans('other-domain-test-params-long-array', array('foo' => 'bar'), 'not_messages'); ?>
4242

43-
<?php echo $view['translator']->transChoice('other-domain-test-trans-choice-short-array-%count%', 10, ['%count%' => 10], 'not_messages'); ?>
43+
<?php echo $view['translator']->transChoice('other-domain-test-trans-choice-short-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?>
4444

4545
<?php echo $view['translator']->transChoice('other-domain-test-trans-choice-long-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?>
4646

47-
<?php echo $view['translator']->trans('typecast', ['a' => (int) '123'], 'not_messages'); ?>
48-
<?php echo $view['translator']->transChoice('msg1', 10 + 1, [], 'not_messages'); ?>
49-
<?php echo $view['translator']->transChoice('msg2', ceil(4.5), [], 'not_messages'); ?>
47+
<?php echo $view['translator']->trans('typecast', array('a' => (int) '123'), 'not_messages'); ?>
48+
<?php echo $view['translator']->transChoice('msg1', 10 + 1, array(), 'not_messages'); ?>
49+
<?php echo $view['translator']->transChoice('msg2', ceil(4.5), array(), 'not_messages'); ?>

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.5.9",
20+
"ext-xml": "*",
2021
"symfony/cache": "~3.3",
2122
"symfony/class-loader": "~3.2",
2223
"symfony/dependency-injection": "~3.3-beta2",

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\Workflow\Workflow;
1819

1920
/**
2021
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
@@ -105,5 +106,12 @@ public function process(ContainerBuilder $container)
105106
if ($container->hasDefinition('twig.extension.expression')) {
106107
$container->getDefinition('twig.extension.expression')->addTag('twig.extension');
107108
}
109+
110+
$container->addResource(new ClassExistenceResource(Workflow::class));
111+
if (!class_exists(Workflow::class) || !$container->has('workflow.registry')) {
112+
$container->removeDefinition('workflow.twig_extension');
113+
} else {
114+
$container->getDefinition('workflow.twig_extension')->addTag('twig.extension');
115+
}
108116
}
109117
}

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
<tag name="translation.extractor" alias="twig" />
116116
</service>
117117

118+
<service id="workflow.twig_extension" class="Symfony\Bridge\Twig\Extension\WorkflowExtension">
119+
<argument type="service" id="workflow.registry" />
120+
</service>
121+
118122
<service id="twig.exception_listener" class="Symfony\Component\HttpKernel\EventListener\ExceptionListener" public="true">
119123
<tag name="kernel.event_subscriber" />
120124
<tag name="monolog.logger" channel="request" />

src/Symfony/Component/Cache/Adapter/RedisAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RedisAdapter extends AbstractAdapter
2020
/**
2121
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client
2222
* @param string $namespace The default namespace
23-
* @param integer $defaultLifetime The default lifetime
23+
* @param int $defaultLifetime The default lifetime
2424
*/
2525
public function __construct($redisClient, $namespace = '', $defaultLifetime = 0)
2626
{

src/Symfony/Component/Console/Application.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Console\Exception\ExceptionInterface;
1515
use Symfony\Component\Console\Formatter\OutputFormatter;
1616
use Symfony\Component\Console\Helper\DebugFormatterHelper;
17+
use Symfony\Component\Console\Helper\Helper;
1718
use Symfony\Component\Console\Helper\ProcessHelper;
1819
use Symfony\Component\Console\Helper\QuestionHelper;
1920
use Symfony\Component\Console\Input\InputInterface;
@@ -672,7 +673,7 @@ public function renderException(\Exception $e, OutputInterface $output)
672673
$output->isVerbose() && 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : ''
673674
);
674675

675-
$len = $this->stringWidth($title);
676+
$len = Helper::strlen($title);
676677

677678
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX;
678679
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
@@ -683,7 +684,7 @@ public function renderException(\Exception $e, OutputInterface $output)
683684
foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) {
684685
foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
685686
// pre-format lines to get the right string length
686-
$lineLength = $this->stringWidth($line) + 4;
687+
$lineLength = Helper::strlen($line) + 4;
687688
$lines[] = array($line, $lineLength);
688689

689690
$len = max($lineLength, $len);
@@ -692,7 +693,7 @@ public function renderException(\Exception $e, OutputInterface $output)
692693

693694
$messages = array();
694695
$messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
695-
$messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title))));
696+
$messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
696697
foreach ($lines as $line) {
697698
$messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
698699
}
@@ -1080,15 +1081,6 @@ public function setDefaultCommand($commandName, $isSingleCommand = false)
10801081
return $this;
10811082
}
10821083

1083-
private function stringWidth($string)
1084-
{
1085-
if (false === $encoding = mb_detect_encoding($string, null, true)) {
1086-
return strlen($string);
1087-
}
1088-
1089-
return mb_strwidth($string, $encoding);
1090-
}
1091-
10921084
private function splitStringByWidth($string, $width)
10931085
{
10941086
// str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function getStyle()
156156
*/
157157
public function setColumnStyle($columnIndex, $name)
158158
{
159-
$columnIndex = intval($columnIndex);
159+
$columnIndex = (int) $columnIndex;
160160

161161
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
162162

@@ -191,7 +191,7 @@ public function getColumnStyle($columnIndex)
191191
*/
192192
public function setColumnWidth($columnIndex, $width)
193193
{
194-
$this->columnWidths[intval($columnIndex)] = intval($width);
194+
$this->columnWidths[(int) $columnIndex] = (int) $width;
195195

196196
return $this;
197197
}

src/Symfony/Component/DependencyInjection/Definition.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Definition
2626
private $factory;
2727
private $shared = true;
2828
private $deprecated = false;
29-
private $deprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.';
29+
private $deprecationTemplate;
3030
private $properties = array();
3131
private $calls = array();
3232
private $instanceof = array();
@@ -44,6 +44,8 @@ class Definition
4444

4545
protected $arguments = array();
4646

47+
private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.';
48+
4749
/**
4850
* @param string|null $class The service class
4951
* @param array $arguments An array of arguments to pass to the service constructor
@@ -710,7 +712,7 @@ public function isDeprecated()
710712
*/
711713
public function getDeprecationMessage($id)
712714
{
713-
return str_replace('%service_id%', $id, $this->deprecationTemplate);
715+
return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate);
714716
}
715717

716718
/**

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
784784
private function startClass($class, $baseClass, $namespace)
785785
{
786786
$bagClass = $this->container->isCompiled() ? 'use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;' : 'use Symfony\Component\DependencyInjection\ParameterBag\\ParameterBag;';
787-
$namespaceLine = $namespace ? "namespace $namespace;\n" : '';
787+
$namespaceLine = $namespace ? "\nnamespace $namespace;\n" : '';
788788

789789
return <<<EOF
790790
<?php

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Symfony\Component\DependencyInjection\Dump;
34

45
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()
156156
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
157157
}
158158

159+
/**
160+
* @group network
161+
*/
159162
public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy()
160163
{
161164
$sourceFilePath = 'http://symfony.com/images/common/logo/logo_symfony_header.png';

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
158158
}
159159

160160
// To avoid issues when the submitted choices are arrays (i.e. array to string conversions),
161-
// we have to ensure that all elements of the submitted choice data are strings or null.
161+
// we have to ensure that all elements of the submitted choice data are NULL, strings or ints.
162162
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
163163
$data = $event->getData();
164164

src/Symfony/Component/Form/Tests/CompoundFormTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14-
use PHPUnit\Framework\TestCase;
1514
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
1615
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
1716
use Symfony\Component\Form\FormError;

src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Csrf\EventListener;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Form\Form;
1615
use Symfony\Component\Form\FormBuilder;
1716
use Symfony\Component\Form\FormEvent;
1817
use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener;

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ public function testGetContentReturnsResourceWhenContentSetInConstructor()
10361036
$req = new Request(array(), array(), array(), array(), array(), array(), 'MyContent');
10371037
$resource = $req->getContent(true);
10381038

1039-
$this->assertTrue(is_resource($resource));
1039+
$this->assertInternalType('resource', $resource);
10401040
$this->assertEquals('MyContent', stream_get_contents($resource));
10411041
}
10421042

src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,15 @@ function ($currency) { return array($currency); },
676676
*/
677677
public function testGetFractionDigits($currency)
678678
{
679-
$this->assertTrue(is_numeric($this->dataProvider->getFractionDigits($currency)));
679+
$this->assertInternalType('numeric', $this->dataProvider->getFractionDigits($currency));
680680
}
681681

682682
/**
683683
* @dataProvider provideCurrencies
684684
*/
685685
public function testGetRoundingIncrement($currency)
686686
{
687-
$this->assertTrue(is_numeric($this->dataProvider->getRoundingIncrement($currency)));
687+
$this->assertInternalType('numeric', $this->dataProvider->getRoundingIncrement($currency));
688688
}
689689

690690
public function provideCurrenciesWithNumericEquivalent()

src/Symfony/Component/Workflow/Tests/EventListener/AuditTrailListenerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use Symfony\Component\Workflow\EventListener\AuditTrailListener;
99
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
1010
use Symfony\Component\Workflow\Tests\WorkflowBuilderTrait;
11-
use Symfony\Component\Workflow\Tests\createSimpleWorkflowDefinition;
12-
use Symfony\Component\Workflow\Transition;
1311
use Symfony\Component\Workflow\Workflow;
1412

1513
class AuditTrailListenerTest extends TestCase

0 commit comments

Comments
 (0)
0