Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '2.1'

* 2.1:
  Restrict Monolog version to be in version <1.3
  [Console] Make getTerminalWith & getTerminalHeight public
  [DependencyInjection] fixed PhpDumper optimizations when an inlined service depends on the current one indirectly
  [DependencyInjection] fixed PhpDumper when an inlined service definition has some properties
  [DependencyInjection] added some tests for PhpDumper when the container is compiled
  [DependencyInjection] fixed CS
  [Process] Do not reset stdout/stderr pipes on Interrupted system call
  [Locale] Adjust `StubIntlDateFormatter` to have new methods added in PHP 5.5
  use the right RequestMatcherInterface
  [Locale] Fix failing `StubIntlDateFormatter` tests in PHP 5.5
  [Locale] Fix failing `StubIntlDateFormatter` in PHP 5.5
  [Form] Fix failing `MonthChoiceList` in PHP 5.5
  Update .travis.yml

Conflicts:
	src/Symfony/Bridge/Monolog/composer.json
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
  • Loading branch information...
commit 6250476eaa2d48e4b72d15cf99a7bd0cd94833c4 2 parents 0887fcb + f1d2fe9
@fabpot fabpot authored
View
5 .travis.yml
@@ -4,6 +4,11 @@ php:
- 5.3.3
- 5.3
- 5.4
+ - 5.5
+
+matrix:
+ allow_failures:
+ - php: 5.5
before_script:
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
View
2  src/Symfony/Bridge/Monolog/composer.json
@@ -18,7 +18,7 @@
"require": {
"php": ">=5.3.3",
"symfony/http-kernel": "2.2.*",
- "monolog/monolog": "1.*"
+ "monolog/monolog": ">=1.0,<1.3-dev"
},
"autoload": {
"psr-0": { "Symfony\\Bridge\\Monolog\\": "" }
View
4 src/Symfony/Component/Console/Application.php
@@ -859,7 +859,7 @@ public function renderException($e, $output)
*
* @return int|null
*/
- protected function getTerminalWidth()
+ public function getTerminalWidth()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if ($ansicon = getenv('ANSICON')) {
@@ -881,7 +881,7 @@ protected function getTerminalWidth()
*
* @return int|null
*/
- protected function getTerminalHeight()
+ public function getTerminalHeight()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if ($ansicon = getenv('ANSICON')) {
View
31 src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
@@ -203,7 +203,7 @@ private function addServiceInlinedDefinitions($id, $definition)
$nbOccurrences->offsetSet($definition, 1);
} else {
$i = $nbOccurrences->offsetGet($definition);
- $nbOccurrences->offsetSet($definition, $i+1);
+ $nbOccurrences->offsetSet($definition, $i + 1);
}
}
@@ -214,7 +214,7 @@ private function addServiceInlinedDefinitions($id, $definition)
$processed->offsetSet($sDefinition);
$class = $this->dumpValue($sDefinition->getClass());
- if ($nbOccurrences->offsetGet($sDefinition) > 1 || count($sDefinition->getMethodCalls()) > 0 || $sDefinition->getProperties() || null !== $sDefinition->getConfigurator() || false !== strpos($class, '$')) {
+ if ($nbOccurrences->offsetGet($sDefinition) > 1 || $sDefinition->getMethodCalls() || $sDefinition->getProperties() || null !== $sDefinition->getConfigurator() || false !== strpos($class, '$')) {
$name = $this->getNextVariableName();
$variableMap->offsetSet($sDefinition, new Variable($name));
@@ -248,7 +248,7 @@ private function addServiceInlinedDefinitions($id, $definition)
$code .= sprintf(" \$%s = new \\%s(%s);\n", $name, substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
}
- if (!$this->hasReference($id, $sDefinition->getMethodCalls()) && !$this->hasReference($id, $sDefinition->getProperties())) {
+ if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) {
$code .= $this->addServiceMethodCalls(null, $sDefinition, $name);
$code .= $this->addServiceProperties(null, $sDefinition, $name);
$code .= $this->addServiceConfigurator(null, $sDefinition, $name);
@@ -417,16 +417,14 @@ private function addServiceInlinedDefinitionsSetup($id, $definition)
}
$processed->offsetSet($iDefinition);
- if (!$this->hasReference($id, $iDefinition->getMethodCalls())) {
+ if (!$this->hasReference($id, $iDefinition->getMethodCalls(), true) && !$this->hasReference($id, $iDefinition->getProperties(), true)) {
continue;
}
- if ($iDefinition->getMethodCalls()) {
- $code .= $this->addServiceMethodCalls(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition));
- }
- if ($iDefinition->getConfigurator()) {
- $code .= $this->addServiceConfigurator(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition));
- }
+ $name = (string) $this->definitionVariables->offsetGet($iDefinition);
+ $code .= $this->addServiceMethodCalls(null, $iDefinition, $name);
+ $code .= $this->addServiceProperties(null, $iDefinition, $name);
+ $code .= $this->addServiceConfigurator(null, $iDefinition, $name);
}
if ('' !== $code) {
@@ -965,17 +963,26 @@ private function getDefinitionsFromArguments(array $arguments)
*
* @return Boolean
*/
- private function hasReference($id, array $arguments)
+ private function hasReference($id, array $arguments, $deep = false)
{
foreach ($arguments as $argument) {
if (is_array($argument)) {
- if ($this->hasReference($id, $argument)) {
+ if ($this->hasReference($id, $argument, $deep)) {
return true;
}
} elseif ($argument instanceof Reference) {
if ($id === (string) $argument) {
return true;
}
+
+ if ($deep) {
+ $service = $this->container->getDefinition((string) $argument);
+ $arguments = array_merge($service->getMethodCalls(), $service->getArguments(), $service->getProperties());
+
+ if ($this->hasReference($id, $arguments, $deep)) {
+ return true;
+ }
+ }
}
}
View
7 src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
@@ -98,10 +98,17 @@ public function testAddParameters()
public function testAddService()
{
+ // without compilation
$container = include self::$fixturesPath.'/containers/container9.php';
$dumper = new PhpDumper($container);
$this->assertEquals(str_replace('%path%', str_replace('\\','\\\\',self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services9.php')), $dumper->dump(), '->dump() dumps services');
+ // with compilation
+ $container = include self::$fixturesPath.'/containers/container9.php';
+ $container->compile();
+ $dumper = new PhpDumper($container);
+ $this->assertEquals(str_replace('%path%', str_replace('\\','\\\\',self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services9_compiled.php')), $dumper->dump(), '->dump() dumps services');
+
$dumper = new PhpDumper($container = new ContainerBuilder());
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
try {
View
25 src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
@@ -14,9 +14,8 @@
addTag('foo', array('bar' => 'bar'))->
setFactoryClass('FooClass')->
setFactoryMethod('getInstance')->
- setArguments(array('foo', new Reference('foo.baz'), array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, new Reference('service_container')))->
+ setArguments(array('foo', new Reference('foo.baz'), array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%'), true, new Reference('service_container')))->
setProperties(array('foo' => 'bar', 'moo' => new Reference('foo.baz')))->
- setScope('prototype')->
addMethodCall('setBar', array(new Reference('bar')))->
addMethodCall('initialize')->
setConfigurator('sc_configure')
@@ -33,7 +32,10 @@
setFactoryMethod('getInstance')->
setConfigurator(array('%baz_class%', 'configureStatic1'))
;
-$container->register('foo_bar', '%foo_class%');
+$container->
+ register('foo_bar', '%foo_class%')->
+ setScope('prototype')
+;
$container->getParameterBag()->clear();
$container->getParameterBag()->add(array(
'baz_class' => 'BazClass',
@@ -50,9 +52,24 @@
addMethodCall('setBar', array(new Reference('foobaz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
;
$container->
- register('factory_service')->
+ register('factory_service', 'Bar')->
setFactoryService('foo.baz')->
setFactoryMethod('getInstance')
;
+$container
+ ->register('foo_with_inline', 'Foo')
+ ->addMethodCall('setBar', array(new Reference('inlined')))
+;
+$container
+ ->register('inlined', 'Bar')
+ ->setProperty('pub', 'pub')
+ ->addMethodCall('setBaz', array(new Reference('baz')))
+ ->setPublic(false)
+;
+$container
+ ->register('baz', 'Baz')
+ ->addMethodCall('setFoo', array(new Reference('foo_with_inline')))
+;
+
return $container;
View
12 src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot
@@ -3,12 +3,15 @@ digraph sc {
node [fontsize="11" fontname="Arial" shape="record"];
edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"];
- node_foo [label="foo (alias_for_foo)\nFooClass\n", shape=record, fillcolor="#eeeeee", style="dotted"];
+ node_foo [label="foo (alias_for_foo)\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_bar [label="bar\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_foo_baz [label="foo.baz\nBazClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
- node_foo_bar [label="foo_bar\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
+ node_foo_bar [label="foo_bar\nFooClass\n", shape=record, fillcolor="#eeeeee", style="dotted"];
node_method_call1 [label="method_call1\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
- node_factory_service [label="factory_service\n\n", shape=record, fillcolor="#eeeeee", style="filled"];
+ node_factory_service [label="factory_service\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"];
+ node_foo_with_inline [label="foo_with_inline\nFoo\n", shape=record, fillcolor="#eeeeee", style="filled"];
+ node_inlined [label="inlined\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"];
+ node_baz [label="baz\nBaz\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"];
node_foo2 [label="foo2\n\n", shape=record, fillcolor="#ff9999", style="filled"];
node_foo3 [label="foo3\n\n", shape=record, fillcolor="#ff9999", style="filled"];
@@ -22,4 +25,7 @@ digraph sc {
node_method_call1 -> node_foo2 [label="setBar()" style="dashed"];
node_method_call1 -> node_foo3 [label="setBar()" style="dashed"];
node_method_call1 -> node_foobaz [label="setBar()" style="dashed"];
+ node_foo_with_inline -> node_inlined [label="setBar()" style="dashed"];
+ node_inlined -> node_baz [label="setBaz()" style="dashed"];
+ node_baz -> node_foo_with_inline [label="setFoo()" style="dashed"];
}
View
13 src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php
@@ -7,10 +7,23 @@ function sc_configure($instance)
class BarClass
{
+ protected $baz;
+
+ public function setBaz(BazClass $baz)
+ {
+ $this->baz = $baz;
+ }
}
class BazClass
{
+ protected $foo;
+
+ public function setFoo(Foo $foo)
+ {
+ $this->foo = $foo;
+ }
+
public function configure($instance)
{
$instance->configure();
View
68 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
@@ -44,12 +44,29 @@ protected function getBarService()
}
/**
+ * Gets the 'baz' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return Baz A Baz instance.
+ */
+ protected function getBazService()
+ {
+ $this->services['baz'] = $instance = new \Baz();
+
+ $instance->setFoo($this->get('foo_with_inline'));
+
+ return $instance;
+ }
+
+ /**
* Gets the 'factory_service' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
- * @return Object An instance returned by foo.baz::getInstance().
+ * @return Bar A Bar instance.
*/
protected function getFactoryServiceService()
{
@@ -59,13 +76,16 @@ protected function getFactoryServiceService()
/**
* Gets the 'foo' service.
*
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
* @return FooClass A FooClass instance.
*/
protected function getFooService()
{
$a = $this->get('foo.baz');
- $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'bar' => $this->getParameter('foo')), true, $this);
+ $this->services['foo'] = $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo')), true, $this);
$instance->setBar($this->get('bar'));
$instance->initialize();
@@ -96,16 +116,30 @@ protected function getFoo_BazService()
/**
* Gets the 'foo_bar' service.
*
- * This service is shared.
- * This method always returns the same instance of the service.
- *
* @return Object A %foo_class% instance.
*/
protected function getFooBarService()
{
$class = $this->getParameter('foo_class');
- return $this->services['foo_bar'] = new $class();
+ return new $class();
+ }
+
+ /**
+ * Gets the 'foo_with_inline' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return Foo A Foo instance.
+ */
+ protected function getFooWithInlineService()
+ {
+ $this->services['foo_with_inline'] = $instance = new \Foo();
+
+ $instance->setBar($this->get('inlined'));
+
+ return $instance;
}
/**
@@ -145,6 +179,28 @@ protected function getAliasForFooService()
}
/**
+ * Gets the 'inlined' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * This service is private.
+ * If you want to be able to request this service from the container directly,
+ * make it public, otherwise you might end up with broken code.
+ *
+ * @return Bar A Bar instance.
+ */
+ protected function getInlinedService()
+ {
+ $this->services['inlined'] = $instance = new \Bar();
+
+ $instance->setBaz($this->get('baz'));
+ $instance->pub = 'pub';
+
+ return $instance;
+ }
+
+ /**
* Gets the default parameters.
*
* @return array An array of the default parameters
View
241 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php
@@ -0,0 +1,241 @@
+<?php
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\Container;
+use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
+use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
+use Symfony\Component\DependencyInjection\Exception\LogicException;
+use Symfony\Component\DependencyInjection\Exception\RuntimeException;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\Parameter;
+use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
+
+/**
+ * ProjectServiceContainer
+ *
+ * This class has been auto-generated
+ * by the Symfony Dependency Injection Component.
+ */
+class ProjectServiceContainer extends Container
+{
+ /**
+ * Constructor.
+ */
+ public function __construct()
+ {
+ $this->parameters = $this->getDefaultParameters();
+
+ $this->services =
+ $this->scopedServices =
+ $this->scopeStacks = array();
+
+ $this->set('service_container', $this);
+
+ $this->scopes = array();
+ $this->scopeChildren = array();
+ }
+
+ /**
+ * Gets the 'bar' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return FooClass A FooClass instance.
+ */
+ protected function getBarService()
+ {
+ $this->services['bar'] = $instance = new \FooClass('foo', $this->get('foo.baz'), $this->getParameter('foo_bar'));
+
+ $this->get('foo.baz')->configure($instance);
+
+ return $instance;
+ }
+
+ /**
+ * Gets the 'baz' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return Baz A Baz instance.
+ */
+ protected function getBazService()
+ {
+ $this->services['baz'] = $instance = new \Baz();
+
+ $instance->setFoo($this->get('foo_with_inline'));
+
+ return $instance;
+ }
+
+ /**
+ * Gets the 'factory_service' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return Bar A Bar instance.
+ */
+ protected function getFactoryServiceService()
+ {
+ return $this->services['factory_service'] = $this->get('foo.baz')->getInstance();
+ }
+
+ /**
+ * Gets the 'foo' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return FooClass A FooClass instance.
+ */
+ protected function getFooService()
+ {
+ $a = $this->get('foo.baz');
+
+ $this->services['foo'] = $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this);
+
+ $instance->setBar($this->get('bar'));
+ $instance->initialize();
+ $instance->foo = 'bar';
+ $instance->moo = $a;
+ sc_configure($instance);
+
+ return $instance;
+ }
+
+ /**
+ * Gets the 'foo.baz' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return BazClass A BazClass instance.
+ */
+ protected function getFoo_BazService()
+ {
+ $this->services['foo.baz'] = $instance = call_user_func(array('BazClass', 'getInstance'));
+
+ call_user_func(array('BazClass', 'configureStatic1'), $instance);
+
+ return $instance;
+ }
+
+ /**
+ * Gets the 'foo_bar' service.
+ *
+ * @return FooClass A FooClass instance.
+ */
+ protected function getFooBarService()
+ {
+ return new \FooClass();
+ }
+
+ /**
+ * Gets the 'foo_with_inline' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return Foo A Foo instance.
+ */
+ protected function getFooWithInlineService()
+ {
+ $a = new \Bar();
+
+ $this->services['foo_with_inline'] = $instance = new \Foo();
+
+ $a->setBaz($this->get('baz'));
+ $a->pub = 'pub';
+
+ $instance->setBar($a);
+
+ return $instance;
+ }
+
+ /**
+ * Gets the 'method_call1' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return FooClass A FooClass instance.
+ */
+ protected function getMethodCall1Service()
+ {
+ require_once '%path%foo.php';
+
+ $this->services['method_call1'] = $instance = new \FooClass();
+
+ $instance->setBar($this->get('foo'));
+ $instance->setBar(NULL);
+
+ return $instance;
+ }
+
+ /**
+ * Gets the alias_for_foo service alias.
+ *
+ * @return FooClass An instance of the foo service
+ */
+ protected function getAliasForFooService()
+ {
+ return $this->get('foo');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getParameter($name)
+ {
+ $name = strtolower($name);
+
+ if (!array_key_exists($name, $this->parameters)) {
+ throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
+ }
+
+ return $this->parameters[$name];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function hasParameter($name)
+ {
+ return array_key_exists(strtolower($name), $this->parameters);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setParameter($name, $value)
+ {
+ throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getParameterBag()
+ {
+ if (null === $this->parameterBag) {
+ $this->parameterBag = new FrozenParameterBag($this->parameters);
+ }
+
+ return $this->parameterBag;
+ }
+ /**
+ * Gets the default parameters.
+ *
+ * @return array An array of the default parameters
+ */
+ protected function getDefaultParameters()
+ {
+ return array(
+ 'baz_class' => 'BazClass',
+ 'foo_class' => 'FooClass',
+ 'foo' => 'bar',
+ );
+ }
+}
View
24 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
@@ -6,14 +6,14 @@
<parameter key="foo">bar</parameter>
</parameters>
<services>
- <service id="foo" class="FooClass" factory-method="getInstance" scope="prototype">
+ <service id="foo" class="FooClass" factory-method="getInstance">
<tag name="foo" foo="foo"/>
<tag name="foo" bar="bar"/>
<argument>foo</argument>
<argument type="service" id="foo.baz"/>
<argument type="collection">
<argument key="%foo%">foo is %foo%</argument>
- <argument key="bar">%foo%</argument>
+ <argument key="foobar">%foo%</argument>
</argument>
<argument>true</argument>
<argument type="service" id="service_container"/>
@@ -34,7 +34,7 @@
<service id="foo.baz" class="%baz_class%" factory-method="getInstance">
<configurator class="%baz_class%" method="configureStatic1"/>
</service>
- <service id="foo_bar" class="%foo_class%"/>
+ <service id="foo_bar" class="%foo_class%" scope="prototype"/>
<service id="method_call1" class="FooClass">
<file>%path%foo.php</file>
<call method="setBar">
@@ -50,7 +50,23 @@
<argument type="service" id="foobaz" on-invalid="ignore"/>
</call>
</service>
- <service id="factory_service" factory-method="getInstance" factory-service="foo.baz"/>
+ <service id="factory_service" class="Bar" factory-method="getInstance" factory-service="foo.baz"/>
+ <service id="foo_with_inline" class="Foo">
+ <call method="setBar">
+ <argument type="service" id="inlined"/>
+ </call>
+ </service>
+ <service id="inlined" class="Bar" public="false">
+ <property name="pub">pub</property>
+ <call method="setBaz">
+ <argument type="service" id="baz"/>
+ </call>
+ </service>
+ <service id="baz" class="Baz">
+ <call method="setFoo">
+ <argument type="service" id="foo_with_inline"/>
+ </call>
+ </service>
<service id="alias_for_foo" alias="foo"/>
</services>
</container>
View
21 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
@@ -10,13 +10,12 @@ services:
- { name: foo, foo: foo }
- { name: foo, bar: bar }
factory_method: getInstance
- arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', bar: '%foo%' }, true, '@service_container']
+ arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', foobar: '%foo%' }, true, '@service_container']
properties: { foo: bar, moo: '@foo.baz' }
calls:
- [setBar, ['@bar']]
- [initialize, { }]
- scope: prototype
configurator: sc_configure
bar:
class: FooClass
@@ -28,6 +27,7 @@ services:
configurator: ['%baz_class%', configureStatic1]
foo_bar:
class: %foo_class%
+ scope: prototype
method_call1:
class: FooClass
file: %path%foo.php
@@ -38,6 +38,23 @@ services:
- [setBar, ['@?foobaz']]
factory_service:
+ class: Bar
factory_method: getInstance
factory_service: foo.baz
+ foo_with_inline:
+ class: Foo
+ calls:
+ - [setBar, ['@inlined']]
+
+ inlined:
+ class: Bar
+ properties: { pub: pub }
+ calls:
+ - [setBaz, ['@baz']]
+
+ baz:
+ class: Baz
+ calls:
+ - [setFoo, ['@foo_with_inline']]
+
alias_for_foo: @foo
View
83 src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php
@@ -189,6 +189,9 @@ public function format($timestamp)
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value ';
} elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) {
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object';
+ if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=') && !is_int($timestamp)) {
+ $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
+ }
}
if (null !== $argumentError) {
@@ -216,6 +219,24 @@ public function format($timestamp)
}
/**
+ * Formats an object
+ *
+ * @param object $object
+ * @param mixed $format
+ * @param string $locale
+ *
+ * @return string The formatted value
+ *
+ * @see http://www.php.net/manual/en/intldateformatter.formatobject.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function formatObject($object, $format = null, $locale = null)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
* Returns the formatter's calendar
*
* @return int The calendar being used by the formatter
@@ -228,6 +249,20 @@ public function getCalendar()
}
/**
+ * Returns the formatter's calendar object
+ *
+ * @return object The calendar's object being used by the formatter
+ *
+ * @see http://www.php.net/manual/en/intldateformatter.getcalendarobject.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function getCalendarObject()
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
* Returns the formatter's datetype
*
* @return int The current value of the formatter
@@ -314,10 +349,29 @@ public function getTimeZoneId()
return $this->timeZoneId;
}
+ // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
+ if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) {
+ return date_default_timezone_get();
+ }
+
return null;
}
/**
+ * Returns the formatter's timezone
+ *
+ * @return mixed The timezone used by the formatter
+ *
+ * @see http://www.php.net/manual/en/intldateformatter.gettimezone.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function getTimeZone()
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
* Returns whether the formatter is lenient
*
* @return Boolean
@@ -457,11 +511,16 @@ public function setPattern($pattern)
public function setTimeZoneId($timeZoneId)
{
if (null === $timeZoneId) {
- // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
- // use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC.
- // See the first two items of the commit message for more information:
- // https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9
- $timeZoneId = getenv('TZ') ?: 'UTC';
+ // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method
+ if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) {
+ $timeZoneId = date_default_timezone_get();
+ } else {
+ // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
+ // use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC.
+ // See the first two items of the commit message for more information:
+ // https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9
+ $timeZoneId = getenv('TZ') ?: 'UTC';
+ }
$this->unitializedTimeZoneId = true;
}
@@ -490,6 +549,20 @@ public function setTimeZoneId($timeZoneId)
}
/**
+ * This method was added in PHP 5.5 as replacement for `setTimeZoneId()`
+ *
+ * @param mixed $timeZone
+ *
+ * @return Boolean true on success or false on failure
+ *
+ * @see http://www.php.net/manual/en/intldateformatter.settimezone.php
+ */
+ public function setTimeZone($timeZone)
+ {
+ return $this->setTimeZoneId($timeZone);
+ }
+
+ /**
* Create and returns a DateTime object with the specified timestamp and with the
* current time zone
*
View
203 src/Symfony/Component/Locale/Tests/Stub/StubIntlDateFormatterTest.php
@@ -41,14 +41,26 @@ public function testConstructor()
public function testConstructorDefaultTimeZoneStub()
{
$formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
- $this->assertNull($formatter->getTimeZoneId());
+
+ // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
+ } else {
+ $this->assertNull($formatter->getTimeZoneId());
+ }
}
public function testConstructorDefaultTimeZoneIntl()
{
$this->skipIfIntlExtensionIsNotLoaded();
$formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
- $this->assertNull($formatter->getTimeZoneId());
+
+ // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
+ } else {
+ $this->assertNull($formatter->getTimeZoneId());
+ }
}
public function testFormatWithUnsupportedTimestampArgument()
@@ -354,6 +366,13 @@ public function testFormatIllegalArgumentErrorIntl($pattern, $timestamp, $errorM
public function formatErrorProvider()
{
+ // With PHP 5.5 IntlDateFormatter accepts empty values ('0')
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ return array(
+ array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR')
+ );
+ }
+
$message = 'datefmt_format: takes either an array or an integer timestamp value : U_ILLEGAL_ARGUMENT_ERROR';
if ($this->isGreaterOrEqualThanPhpVersion('5.3.4')) {
@@ -389,7 +408,7 @@ public function testFormatWithTimezoneIntl($timestamp, $timezone, $expected)
public function formatWithTimezoneProvider()
{
- return array(
+ $data = array(
array(0, 'UTC', '1970-01-01 00:00:00'),
array(0, 'GMT', '1970-01-01 00:00:00'),
array(0, 'GMT-03:00', '1969-12-31 21:00:00'),
@@ -413,12 +432,17 @@ public function formatWithTimezoneProvider()
array(0, 'Europe/Dublin', '1970-01-01 01:00:00'),
array(0, 'Europe/Warsaw', '1970-01-01 01:00:00'),
array(0, 'Pacific/Fiji', '1970-01-01 12:00:00'),
+ );
+ // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC
+ if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
// When time zone not exists, uses UTC by default
- array(0, 'Foo/Bar', '1970-01-01 00:00:00'),
- array(0, 'UTC+04:30', '1970-01-01 00:00:00'),
- array(0, 'UTC+04:AA', '1970-01-01 00:00:00'),
- );
+ $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00');
+ $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00');
+ $data[] = array(0, 'UTC+04:AA', '1970-01-01 00:00:00');
+ }
+
+ return $data;
}
/**
@@ -427,7 +451,13 @@ public function formatWithTimezoneProvider()
public function testFormatWithTimezoneFormatOptionAndDifferentThanUtcStub()
{
$formatter = $this->createStubFormatter('zzzz');
- $formatter->setTimeZoneId('Pacific/Fiji');
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone('Pacific/Fiji');
+ } else {
+ $formatter->setTimeZoneId('Pacific/Fiji');
+ }
+
$formatter->format(0);
}
@@ -435,7 +465,12 @@ public function testFormatWithTimezoneFormatOptionAndDifferentThanUtcIntl()
{
$this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter('zzzz');
- $formatter->setTimeZoneId('Pacific/Fiji');
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone('Pacific/Fiji');
+ } else {
+ $formatter->setTimeZoneId('Pacific/Fiji');
+ }
$expected = $this->isGreaterOrEqualThanIcuVersion('49') ? 'Fiji Standard Time' : 'Fiji Time';
$this->assertEquals($expected, $formatter->format(0));
@@ -444,7 +479,13 @@ public function testFormatWithTimezoneFormatOptionAndDifferentThanUtcIntl()
public function testFormatWithGmtTimezoneStub()
{
$formatter = $this->createStubFormatter('zzzz');
- $formatter->setTimeZoneId('GMT+03:00');
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone('GMT+03:00');
+ } else {
+ $formatter->setTimeZoneId('GMT+03:00');
+ }
+
$this->assertEquals('GMT+03:00', $formatter->format(0));
}
@@ -452,7 +493,13 @@ public function testFormatWithGmtTimezoneIntl()
{
$this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter('zzzz');
- $formatter->setTimeZoneId('GMT+03:00');
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone('GMT+03:00');
+ } else {
+ $formatter->setTimeZoneId('GMT+03:00');
+ }
+
$this->assertEquals('GMT+03:00', $formatter->format(0));
}
@@ -483,6 +530,10 @@ public function testFormatWithDefaultTimezoneIntl()
public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariableWhenAvailable()
{
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $this->markTestSkipped('StubIntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
+ }
+
$tz = getenv('TZ');
putenv('TZ=Europe/London');
@@ -500,6 +551,29 @@ public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariab
putenv('TZ='.$tz);
}
+ public function testFormatWithDefaultTimezoneStubShouldUseDefaultDateTimeZoneVariable()
+ {
+ if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $this->markTestSkipped('Only in PHP 5.5 StubIntlDateFormatter depends on default timezone (`date_default_timezone_get()`).');
+ }
+
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('Europe/London');
+
+ $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
+ $formatter->setPattern('yyyy-MM-dd HH:mm:ss');
+
+ $this->assertEquals(
+ $this->createDateTime(0)->format('Y-m-d H:i:s'),
+ $formatter->format(0)
+ );
+
+ $this->assertEquals('Europe/London', date_default_timezone_get());
+
+ // Restores TZ.
+ date_default_timezone_set($tz);
+ }
+
/**
* It seems IntlDateFormatter caches the timezone id when not explicitly set via constructor or by the
* setTimeZoneId() method. Since testFormatWithDefaultTimezoneIntl() runs using the default environment
@@ -509,6 +583,10 @@ public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariab
*/
public function testFormatWithDefaultTimezoneIntlShouldUseTheTzEnvironmentVariableWhenAvailable()
{
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
+ }
+
$this->skipIfIntlExtensionIsNotLoaded();
$this->skipIfICUVersionIsTooOld();
@@ -530,6 +608,35 @@ public function testFormatWithDefaultTimezoneIntlShouldUseTheTzEnvironmentVariab
}
/**
+ * @runInSeparateProcess
+ */
+ public function testFormatWithDefaultTimezoneIntlShouldUseDefaultDateTimeZoneVariable()
+ {
+ if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).');
+ }
+
+ $this->skipIfIntlExtensionIsNotLoaded();
+ $this->skipIfICUVersionIsTooOld();
+
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('Europe/Paris');
+
+ $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
+ $formatter->setPattern('yyyy-MM-dd HH:mm:ss');
+
+ $this->assertEquals('Europe/Paris', date_default_timezone_get());
+
+ $this->assertEquals(
+ $this->createDateTime(0)->format('Y-m-d H:i:s'),
+ $formatter->format(0)
+ );
+
+ // Restores TZ.
+ date_default_timezone_set($tz);
+ }
+
+ /**
* @expectedException Symfony\Component\Locale\Exception\NotImplementedException
*/
public function testFormatWithUnimplementedCharsStub()
@@ -1017,38 +1124,59 @@ public function testSetPattern()
* @covers Symfony\Component\Locale\Stub\StubIntlDateFormatter::getTimeZoneId
* @dataProvider setTimeZoneIdProvider()
*/
- public function testSetTimeZoneIdStub($timeZoneId)
+ public function testSetTimeZoneIdStub($timeZoneId, $expectedTimeZoneId)
{
$formatter = $this->createStubFormatter();
- $formatter->setTimeZoneId($timeZoneId);
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone($timeZoneId);
+ } else {
+ $formatter->setTimeZoneId($timeZoneId);
+ }
+
$this->assertEquals($timeZoneId, $formatter->getTimeZoneId());
}
/**
* @dataProvider setTimeZoneIdProvider()
*/
- public function testSetTimeZoneIdIntl($timeZoneId)
+ public function testSetTimeZoneIdIntl($timeZoneId, $expectedTimeZoneId)
{
$this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter();
- $formatter->setTimeZoneId($timeZoneId);
- $this->assertEquals($timeZoneId, $formatter->getTimeZoneId());
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone($timeZoneId);
+ } else {
+ $formatter->setTimeZoneId($timeZoneId);
+ }
+
+ $this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId());
}
public function setTimeZoneIdProvider()
{
- return array(
- array('UTC'),
- array('GMT'),
- array('GMT-03:00'),
- array('GMT-0300'),
- array('Europe/Zurich'),
-
- // When time zone not exists, uses UTC by default
- array('Foo/Bar'),
- array('GMT+00:AA'),
- array('GMT+00AA'),
+ $data = array(
+ array('UTC', 'UTC'),
+ array('GMT', 'GMT'),
+ array('GMT-03:00', 'GMT-03:00'),
+ array('Europe/Zurich', 'Europe/Zurich'),
);
+
+ // When time zone not exists, uses UTC by default
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $data[] = array('GMT-0300', 'UTC');
+ $data[] = array('Foo/Bar', 'UTC');
+ $data[] = array('GMT+00:AA', 'UTC');
+ $data[] = array('GMT+00AA', 'UTC');
+ } else {
+ $data[] = array('GMT-0300', 'GMT-0300');
+ $data[] = array('Foo/Bar', 'Foo/Bar');
+ $data[] = array('GMT+00:AA', 'GMT+00:AA');
+ $data[] = array('GMT+00AA', 'GMT+00AA');
+ }
+
+ return $data;
}
/**
@@ -1057,14 +1185,25 @@ public function setTimeZoneIdProvider()
public function testSetTimeZoneIdWithGmtTimeZoneWithMinutesOffsetStub()
{
$formatter = $this->createStubFormatter();
- $formatter->setTimeZoneId('GMT+00:30');
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone('GMT+00:30');
+ } else {
+ $formatter->setTimeZoneId('GMT+00:30');
+ }
}
public function testSetTimeZoneIdWithGmtTimeZoneWithMinutesOffsetIntl()
{
$this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter();
- $formatter->setTimeZoneId('GMT+00:30');
+
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $formatter->setTimeZone('GMT+00:30');
+ } else {
+ $formatter->setTimeZoneId('GMT+00:30');
+ }
+
$this->assertEquals('GMT+00:30', $formatter->getTimeZoneId());
}
@@ -1086,7 +1225,11 @@ protected function createIntlFormatter($pattern = null)
protected function createDateTime($timestamp = null)
{
- $timeZone = getenv('TZ') ?: 'UTC';
+ if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
+ $timeZone = date_default_timezone_get();
+ } else {
+ $timeZone = getenv('TZ') ?: 'UTC';
+ }
$dateTime = new \DateTime();
$dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);
View
9 src/Symfony/Component/Process/Process.php
@@ -384,10 +384,13 @@ public function wait($callback = null)
$w = null;
$e = null;
- $n = @stream_select($r, $w, $e, $this->timeout);
+ if (false === $n = @stream_select($r, $w, $e, $this->timeout)) {
+ $lastError = error_get_last();
- if (false === $n) {
- $this->pipes = array();
+ // stream_select returns false when the `select` system call is interrupted by an incoming signal
+ if (isset($lastError['message']) && false === stripos($lastError['message'], 'interrupted system call')) {
+ $this->pipes = array();
+ }
continue;
}
View
2  src/Symfony/Component/Security/Http/HttpUtils.php
@@ -16,7 +16,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
-use Symfony\Component\HttpFoundation\RequestMatcherInterface;
+use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
Please sign in to comment.
Something went wrong with that request. Please try again.