8000 Merge branch '3.0' · symfony/symfony@a99d713 · GitHub
[go: up one dir, main page]

Skip to content

Commit a99d713

Browse files
committed
Merge branch '3.0'
* 3.0: #17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features #17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features Fix bug when using an private aliased factory service [Form] fix tests added by #17798 by removing `choices_as_values` [Form] fix FQCN in tests added by #17798 [DependencyInjection] Remove unused parameter of private property bug #17798 [Form] allow `choice_label` option to be `false` [Form] fix tests added by #17760 with FQCN ChoiceFormField of type "select" could be "disabled" Update contributing docs [Console] Fix escaping of trailing backslashes Fix constraint validator alias being required [DependencyInjection] Simplified code in AutowirePass [ci] clone with depth=1 to kill push-forced PRs Add check on If-Range header
2 parents 34f3294 + 1618f10 commit a99d713

File tree

27 files changed

+871
-74
lines changed

27 files changed

+871
-74
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| Q | A
22
| ------------- | ---
3+
| Branch | master for features and deprecations / lowest applicable and maintained version otherwise
34
| Bug fix? | yes/no
45
| New feature? | yes/no
56
| BC breaks? | yes/no

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ language: php
22

33
sudo: false
44

5+
git:
6+
depth: 1
7+
58
addons:
69
apt_packages:
710
- parallel

CONTRIBUTING.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ Symfony is an open source, community-driven project.
55

66
If you'd like to contribute, please read the following documents:
77

8-
* [Contributing Code][1]: The document index related to contributions;
8+
* [Reporting a Bug][1]
9+
* [Submitting a Patch][2]
10+
* [Symfony Core Team][3]
11+
* [Security Issues][4]
12+
* [Running Symfony Tests][5]
13+
* [Our Backwards Compatibility Promise][6]
14+
* [Coding Standards][7]
15+
* [Conventions][8]
916

10-
* [Submitting a Patch][2]: Guidelines for submitting a pull request;
11-
12-
* [Pull Request Template][3]: Template header to use in your pull request
13-
description;
14-
15-
* [Backwards Compatibility][4]: Backward compatibility rules.
16-
17-
[1]: https://symfony.com/doc/current/contributing/code/index.html
18-
[2]: https://symfony.com/doc/current/contributing/code/patches.html#check-list
19-
[3]: https://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request
20-
[4]: https://symfony.com/doc/current/contributing/code/bc.html#working-on-symfony-code
17+
[1]: https://symfony.com/doc/current/contributing/code/bugs.html
18+
[2]: https://symfony.com/doc/current/contributing/code/patches.html
19+
[3]: https://symfony.com/doc/current/contributing/code/core_team.html
20+
[4]: https://symfony.com/doc/current/contributing/code/security.html
21+
[5]: https://symfony.com/doc/current/contributing/code/tests.html
22+
[6]: https://symfony.com/doc/current/contributing/code/bc.html
23+
[7]: https://symfony.com/doc/current/contributing/code/standards.html
24+
[8]: https://symfony.com/doc/current/contributing/code/conventions.html

appveyor.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
build: false
2-
shallow_clone: true
3-
platform: x86
2+
clone_depth: 1
43
clone_folder: c:\projects\symfony
54

65
cache:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"doctrine/orm": "~2.4,>=2.4.5",
8383
"doctrine/doctrine-bundle": "~1.4",
8484
"monolog/monolog": "~1.11",
85-
"ocramius/proxy-manager": "~0.4|~1.0",
85+
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
8686
"egulias/email-validator": "~1.2",
8787
"symfony/polyfill-apcu": "~1.1",
8888
"symfony/security-acl": "~2.8|~3.0",

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,16 @@ public function getProxyFactoryCode(Definition $definition, $id)
7474
$methodName = 'get'.Container::camelize($id).'Service';
7575
$proxyClass = $this->getProxyClassName($definition);
7676

77+
$generatedClass = $this->generateProxyClass($definition);
78+
79+
$constructorCall = $generatedClass->hasMethod('staticProxyConstructor')
80+
? $proxyClass.'::staticProxyConstructor'
81+
: 'new '.$proxyClass;
82+
7783
return <<<EOF
7884
if (\$lazyLoad) {
7985
80-
$instantiation new $proxyClass(
86+
$instantiation $constructorCall(
8187
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) {
8288
\$wrappedInstance = \$this->$methodName(false);
8389
@@ -97,11 +103,7 @@ function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy)
97103
*/
98104
public function getProxyCode(Definition $definition)
99105
{
100-
$generatedClass = new ClassGenerator($this->getProxyClassName($definition));
101-
102-
$this->proxyGenerator->generate(new \ReflectionClass($definition->getClass()), $generatedClass);
103-
104-
return $this->classGenerator->generate($generatedClass);
106+
return $this->classGenerator->generate($this->generateProxyClass($definition));
105107
}
106108

107109
/**
@@ -115,4 +117,16 @@ private function getProxyClassName(Definition $definition)
115117
{
116118
return str_replace('\\', '', $definition->getClass()).'_'.spl_object_hash($definition).$this->salt;
117119
}
120+
121+
/**
122+
* @return ClassGenerator
123+
*/
124+
private function generateProxyClass(Definition $definition)
125+
{
126+
$generatedClass = new ClassGenerator($this->getProxyClassName($definition));
127+
128+
$this->proxyGenerator->generate(new \ReflectionClass($definition->getClass()), $generatedClass);
129+
130+
return $generatedClass;
131+
}
118132
}

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php

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

1212
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper;
1313

14+
use ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\StaticProxyConstructor;
1415
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
@@ -49,7 +50,11 @@ public function testDumpContainerWithProxyService()
4950
*/
5051
public function testDumpContainerWithProxyServiceWillShareProxies()
5152
{
52-
require_once __DIR__.'/../Fixtures/php/lazy_service.php';
53+
if (class_exists(StaticProxyConstructor::class)) { // detecting ProxyManager v2
54+
require_once __DIR__.'/../Fixtures/php/lazy_service_with_hints.php';
55+
} else {
56+
require_once __DIR__.'/../Fixtures/php/lazy_service.php';
57+
}
5358

5459
$container = new \LazyServiceProjectServiceContainer();
5560

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ProjectServiceContainer extends Container
77
{
88
if ($lazyLoad) {
99

10-
return $this->services['foo'] = new stdClass_%s(
10+
return $this->services['foo'] =%sstdClass_%s(
1111
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {
1212
$wrappedInstance = $this->getFooService(false);
1313

@@ -22,5 +22,5 @@ class ProjectServiceContainer extends Container
2222
}
2323
}
2424

25-
class stdClass_%s extends \stdClass implements \ProxyManager\Proxy\VirtualProxyInterface
25+
class stdClass_%s extends \stdClass implements \ProxyManager\%s
2626
{%a}%A
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\ContainerInterface;
4+
use Symfony\Component\DependencyInjection\Container;
5+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
6+
use Symfony\Component\DependencyInjection\Exception\LogicException;
7+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
8+
use Symfony\Component\DependencyInjection\Reference;
9+
use Symfony\Component\DependencyInjection\Parameter;
10+
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
11+
12+
/**
13+
* ProjectServiceContainer.
14+
*
15+
* This class has been auto-generated
16+
* by the Symfony Dependency Injection Component.
17+
*/
18+
class LazyServiceProjectServiceContainer extends Container
19+
{
20+
/**
21+
* Constructor.
22+
*/
23+
public function __construct()
24+
{
25+
$this->services = array();
26+
}
27+
28+
/**
29+
* Gets the 'foo' service.
30+
*
31+
* This service is shared.
32+
* This method always returns the same instance of the service.
33+
*
34+
* @param bool $lazyLoad whether to try lazy-loading the service with a proxy
35+
*
36+
* @return stdClass A stdClass instance.
37+
*/
38+
public function getFooService($lazyLoad = true)
39+
{
40+
if ($lazyLoad) {
41+
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
42+
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {
43+
$wrappedInstance = $this->getFooService(false);
44+
45+
$proxy->setProxyInitializer(null);
46+
47+
return true;
48+
}
49+
);
50+
}
51+
52+
return new \stdClass();
53+
}
54+
}
55+
56+
class stdClass_c1d194250ee2e2b7d2eab8b8212368a8 extends \stdClass implements \ProxyManager\Proxy\LazyLoadingInterface, \ProxyManager\Proxy\ValueHolderInterface
57+
{
58+
/**
59+
* @var \Closure|null initializer responsible for generating the wrapped object
60+
*/
61+
private $valueHolder5157dd96e88c0 = null;
62+
63+
/**
64+
* @var \Closure|null initializer responsible for generating the wrapped object
65+
*/
66+
private $initializer5157dd96e8924 = null;
67+
68+
/**
69+
* @override constructor for lazy initialization
70+
*
71+
* @param \Closure|null $initializer
72+
*/
73+
public function __construct($initializer)
74+
{
75+
$this->initializer5157dd96e8924 = $initializer;
76+
}
77+
78+
/**
79+
* @param string $name
80+
*/
81+
public function __get($name)
82+
{
83+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__get', array('name' => $name));
84+
85+
return $this->valueHolder5157dd96e88c0->$name;
86+
}
87+
88+
/**
89+
* @param string $name
90+
* @param mixed $value
91+
*/
92+
public function __set($name, $value)
93+
{
94+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__set', array('name' => $name, 'value' => $value));
95+
96+
$this->valueHolder5157dd96e88c0->$name = $value;
97+
}
98+
99+
/**
100+
* @param string $name
101+
*
102+
* @return bool
103+
*/
104+
public function __isset($name)
105+
{
106+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__isset', array('name' => $name));
107+
108+
return isset($this->valueHolder5157dd96e88c0->$name);
109+
}
110+
111+
/**
112+
* @param string $name
113+
*/
114+
public function __unset($name)
115+
{
116+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__unset', array('name' => $name));
117+
118+
unset($this->valueHolder5157dd96e88c0->$name);
119+
}
120+
121+
/**
122+
*
123+
*/
124+
public function __clone()
125+
{
126+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__clone', array());
127+
128+
$this->valueHolder5157dd96e88c0 = clone $this->valueHolder5157dd96e88c0;
129+
}
130+
131+
/**
132+
*
133+
*/
134+
public function __sleep()
135+
{
136+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__sleep', array());
137+
138+
return array('valueHolder5157dd96e88c0');
139+
}
140+
141+
/**
142+
*
143+
*/
144+
public function __wakeup()
145+
{
146+
}
147+
148+
/**
149+
* {@inheritdoc}
150+
*/
151+
public function setProxyInitializer(\Closure $initializer = null)
152+
{
153+
$this->initializer5157dd96e8924 = $initializer;
154+
}
155+
156+
/**
157+
* {@inheritdoc}
158+
*/
159+
public function getProxyInitializer()
160+
{
161+
return $this->initializer5157dd96e8924;
162+
}
163+
164+
/**
165+
* {@inheritdoc}
166+
*/
167+
public function initializeProxy() : bool
168+
{
169+
return $this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, 'initializeProxy', array());
170+
}
171+
172+
/**
173+
* {@inheritdoc}
174+
*/
175+
public function isProxyInitialized() : bool
176+
{
177+
return null !== $this->valueHolder5157dd96e88c0;
178+
}
179+
180+
/**
181+
* {@inheritdoc}
182+
*/
183+
public function getWrappedValueHolderValue()
184+
{
185+
return $this->valueHolder5157dd96e88c0;
186+
}
187+
}

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testGetProxyFactoryCode()
6969
$code = $this->dumper->getProxyFactoryCode($definition, 'foo');
7070

7171
$this->assertStringMatchesFormat(
72-
'%wif ($lazyLoad) {%wreturn $this->services[\'foo\'] = new '
72+
'%wif ($lazyLoad) {%wreturn $this->services[\'foo\'] =%s'
7373
.'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction '
7474
.'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {'
7575
.'%w$wrappedInstance = $this->getFooService(false);%w$proxy->setProxyInitializer(null);'

src/Symfony/Bridge/ProxyManager/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"symfony/dependency-injection": "~2.8|~3.0",
21-
"ocramius/proxy-manager": "~0.4|~1.0"
21+
"ocramius/proxy-manager": "~0.4|~1.0|~2.0"
2222
},
2323
"require-dev": {
2424
"symfony/config": "~2.8|~3.0"

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConstraintValidatorsPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public function process(ContainerBuilder $container)
2727
if (isset($attributes[0]['alias'])) {
2828
$validators[$attributes[0]['alias']] = $id;
2929
}
30+
31+
$validators[$container->getDefinition($id)->getClass()] = $id;
3032
}
3133

3234
$container->getDefinition('validator.validator_factory')->replaceArgument(1, $validators);

0 commit comments

Comments
 (0)
0