Skip to content
Permalink
Browse files

Merge branch '2.8' into 3.4

* 2.8:
  Add code of Conduct links in our README
  [DI] never inline lazy services
  Default testsuite to latest PHPUnit 6.*
  [Github] Update the pull-request template
  bumped Symfony version to 2.8.42
  updated VERSION for 2.8.41
  updated CHANGELOG for 2.8.41
  • Loading branch information...
nicolas-grekas committed May 25, 2018
2 parents 79bd461 + 4279f53 commit bf202600252c9b260660d05db55bc3e5a9982955
@@ -1,6 +1,6 @@
| Q | A
| ------------- | ---
| Branch? | master for features / 2.7 up to 4.0 for bug fixes <!-- see below -->
| Branch? | master for features / 2.8 up to 4.1 for bug fixes <!-- see below -->
| Bug fix? | yes/no
| New feature? | yes/no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
@@ -29,6 +29,7 @@ Community
* [Join the Symfony Community][11] and meet other members at the [Symfony events][12].
* [Get Symfony support][13] on Stack Overflow, Slack, IRC, etc.
* Follow us on [GitHub][14], [Twitter][15] and [Facebook][16].
* Read our [Code of Conduct][24] and meet the [CARE Team][25]
Contributing
------------
@@ -71,3 +72,5 @@ Symfony development is sponsored by [SensioLabs][21], led by the
[21]: https://sensiolabs.com
[22]: https://symfony.com/doc/current/contributing/code/core_team.html
[23]: https://github.com/symfony/symfony-demo
[24]: https://symfony.com/coc
[25]: https://symfony.com/doc/current/contributing/code_of_conduct/care_team.html
@@ -8,7 +8,7 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
exit(1);
}
if (\PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.0');
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
}
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
@@ -106,11 +106,15 @@ protected function processValue($value, $isRoot = false)
*/
private function isInlineableDefinition($id, Definition $definition, ServiceReferenceGraph $graph)
{
if ($definition->getErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic()) {
return false;
}
if (!$definition->isShared()) {
return true;
}
if ($definition->isDeprecated() || $definition->isPublic() || $definition->isPrivate() || $definition->isLazy()) {
if ($definition->isPublic() || $definition->isPrivate()) {
return false;
}
@@ -11,7 +11,6 @@
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
use DummyProxyDumper;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Symfony\Component\Config\FileLocator;
@@ -490,6 +489,19 @@ public function testInlinedDefinitionReferencingServiceContainer()
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services13.php', $dumper->dump(), '->dump() dumps inline definitions which reference service_container');
}
public function testNonSharedLazyDefinitionReferences()
{
$container = new ContainerBuilder();
$container->register('foo', 'stdClass')->setShared(false)->setLazy(true);
$container->register('bar', 'stdClass')->addArgument(new Reference('foo', ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, false));
$container->compile();
$dumper = new PhpDumper($container);
$dumper->setProxyDumper(new \DummyProxyDumper());
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_non_shared_lazy.php', $dumper->dump());
}
public function testInitializePropertiesBeforeMethodCalls()
{
require_once self::$fixturesPath.'/includes/classes.php';
@@ -558,7 +570,7 @@ public function testCircularReferenceAllowanceForInlinedDefinitionsForLazyServic
$dumper = new PhpDumper($container);
$dumper->setProxyDumper(new DummyProxyDumper());
$dumper->setProxyDumper(new \DummyProxyDumper());
$dumper->dump();
$this->addToAssertionCount(1);
@@ -85,17 +85,17 @@ class DummyProxyDumper implements ProxyDumper
{
public function isProxyCandidate(Definition $definition)
{
return false;
return $definition->isLazy();
}
public function getProxyFactoryCode(Definition $definition, $id, $factoryCall = null)
{
return '';
return " // lazy factory\n\n";
}
public function getProxyCode(Definition $definition)
{
return '';
return "// proxy code\n";
}
}
@@ -0,0 +1,92 @@
<?php
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
*/
class ProjectServiceContainer extends Container
{
private $parameters;
private $targetDirs = array();
public function __construct()
{
$this->services = array();
$this->methodMap = array(
'bar' => 'getBarService',
'foo' => 'getFooService',
);
$this->privates = array(
'bar' => true,
'foo' => true,
);
$this->aliases = array();
}
public function getRemovedIds()
{
return array(
'Psr\\Container\\ContainerInterface' => true,
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
'bar' => true,
'foo' => true,
);
}
public function compile()
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}
public function isCompiled()
{
return true;
}
public function isFrozen()
{
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
return true;
}
protected function createProxy($class, \Closure $factory)
{
return $factory();
}
/**
* Gets the private 'bar' shared service.
*
* @return \stdClass
*/
protected function getBarService()
{
return $this->services['bar'] = new \stdClass(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->getFooService()) && false ?: '_'});
}
/**
* Gets the private 'foo' service.
*
* @return \stdClass
*/
protected function getFooService($lazyLoad = true)
{
// lazy factory
return new \stdClass();
}
}
// proxy code

0 comments on commit bf20260

Please sign in to comment.
You can’t perform that action at this time.