8000 Merge branch '2.7' into 2.8 · symfony/symfony@caf2871 · GitHub
[go: up one dir, main page]

Skip to content

Commit caf2871

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: #17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features Fix bug when using an private aliased factory service ChoiceFormField of type "select" could be "disabled" Update contributing docs [Console] Fix escaping of trailing backslashes Fix constraint validator alias being required [ci] clone with depth=1 to kill push-forced PRs Add check on If-Range header
2 parents feed607 + 51a71ab commit caf2871

File tree

21 files changed

+447
-32
lines changed

21 files changed

+447
-32
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
@@ -84,7 +84,7 @@
8484
"doctrine/orm": "~2.4,>=2.4.5",
8585
"doctrine/doctrine-bundle": "~1.2",
8686
"monolog/monolog": "~1.11",
87-
"ocramius/proxy-manager": "~0.4|~1.0",
87+
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
8888
"egulias/email-validator": "~1.2",
8989
"phpdocumentor/reflection": "^1.0.7"
9090
},

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,17 @@ public function getProxyFactoryCode(Definition $definition, $id)
7979
$methodName = 'get'.Container::camelize($id).'Service';
8080
$proxyClass = $this->getProxyClassName($definition);
8181

82+
$generatedClass = $this->generateProxyClass($definition);
83+
84+
$constructorCall = $generatedClass->hasMethod('staticProxyConstructor')
85+
? $proxyClass.'::staticProxyConstructor'
86+
: 'new '.$proxyClass;
87+
8288
return <<<EOF
8389
if (\$lazyLoad) {
8490
\$container = \$this;
8591
86-
$instantiation new $proxyClass(
92+
$instantiation $constructorCall(
8793
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
8894
\$wrappedInstance = \$container->$methodName(false);
8995
@@ -103,11 +109,7 @@ function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy)
103109
*/
104110
public function getProxyCode(Definition $definition)
105111
{
106-
$generatedClass = new ClassGenerator($this->getProxyClassName($definition));
107-
108-
$this->proxyGenerator->generate(new \ReflectionClass($definition->getClass()), $generatedClass);
109-
110-
return $this->classGenerator->generate($generatedClass);
112+
return $this->classGenerator->generate($this->generateProxyClass($definition));
111113
}
112114

113115
/**
@@ -121,4 +123,18 @@ private function getProxyClassName(Definition $definition)
121123
{
122124
return str_replace('\\', '', $definition->getClass()).'_'.spl_object_hash($definition).$this->salt;
123125
}
126+
127+
/**
128+
* @param Definition $definition
129+
*
130+
* @return ClassGenerator
131+
*/
132+
private function generateProxyClass(Definition $definition)
133+
{
134+
$generatedClass = new ClassGenerator($this->getProxyClassName($definition));
135+
136+
$this->proxyGenerator->generate(new \ReflectionClass($definition->getClass()), $generatedClass);
137+
138+
return $generatedClass;
139+
}
124140
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ public function testDumpContainerWithProxyService()
4949
*/
5050
public function testDumpContainerWithProxyServiceWillShareProxies()
5151
{
52-
require_once __DIR__.'/../Fixtures/php/lazy_service.php';
52+
// detecting ProxyManager v2
53+
if (class_exists('ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\StaticProxyConstructor')) {
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
@@ -8,7 +8,7 @@ class ProjectServiceContainer extends Container
88
if ($lazyLoad) {
99
$container = $this;
1010

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

@@ -23,5 +23,5 @@ class ProjectServiceContainer extends Container
2323
}
2424
}
2525

26-
class stdClass_%s extends \stdClass implements \ProxyManager\Proxy\VirtualProxyInterface
26+
class stdClass_%s extends \stdClass implements \ProxyManager\%s
2727
{%a}%A
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
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+
$container = $this;
42+
43+
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
44+
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
45+
$wrappedInstance = $this->getFooService(false);
46+
47+
$proxy->setProxyInitializer(null);
48+
49+
return true;
50+
}
51+
);
52+
}
53+
54+
return new \stdClass();
55+
}
56+
}
57+
58+
class stdClass_c1d194250ee2e2b7d2eab8b8212368a8 extends \stdClass implements \ProxyManager\Proxy\LazyLoadingInterface, \ProxyManager\Proxy\ValueHolderInterface
59+
{
60+
/**
61+
* @var \Closure|null initializer responsible for generating the wrapped object
62+
*/
63+
private $valueHolder5157dd96e88c0 = null;
64+
65+
/**
66+
* @var \Closure|null initializer responsible for generating the wrapped object
67+
*/
68+
private $initializer5157dd96e8924 = null;
69+
70+
/**
71+
* @override constructor for lazy initialization
72+
*
73+
* @param \Closure|null $initializer
74+
*/
75+
public function __construct($initializer)
76+
{
77+
$this->initializer5157dd96e8924 = $initializer;
78+
}
79+
80+
/**
81+
* @param string $name
82+
*/
83+
public function __get($name)
84+
{
85+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__get', array('name' => $name));
86+
87+
return $this->valueHolder5157dd96e88c0->$name;
88+
}
89+
90+
/**
91+
* @param string $name
92+
* @param mixed $value
93+
*/
94+
public function __set($name, $value)
95+
{
96+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__set', array('name' => $name, 'value' => $value));
97+
98+
$this->valueHolder5157dd96e88c0->$name = $value;
99+
}
100+
101+
/**
102+
* @param string $name
103+
*
104+
* @return bool
105+
*/
106+
public function __isset($name)
107+
{
108+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__isset', array('name' => $name));
109+
110+
return isset($this->valueHolder5157dd96e88c0->$name);
111+
}
112+
113+
/**
114+
* @param string $name
115+
*/
116+
public function __unset($name)
117+
{
118+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__unset', array('name' => $name));
119+
120+
unset($this->valueHolder5157dd96e88c0->$name);
121+
}
122+
123+
/**
124+
*
125+
*/
126+
public function __clone()
127+
{
128+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__clone', array());
129+
130+
$this->valueHolder5157dd96e88c0 = clone $this->valueHolder5157dd96e88c0;
131+
}
132+
133+
/**
134+
*
135+
*/
136+
public function __sleep()
137+
{
138+
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__sleep', array());
139+
140+
return array('valueHolder5157dd96e88c0');
141+
}
142+
143+
/**
144+
*
145+
*/
146+
public function __wakeup()
147+
{
148+
}
149+
150+
/**
151+
* {@inheritdoc}
152+
*/
153+
public function setProxyInitializer(\Closure $initializer = null)
154+
{
155+
$this->initializer5157dd96e8924 = $initializer;
156+
}
157+
158+
/**
159+
* {@inheritdoc}
160+
*/
161+
public function getProxyInitializer()
162+
{
163+
return $this->initializer5157dd96e8924;
164+
}
165+
166+
/**
167+
* {@inheritdoc}
168+
*/
169+
public function initializeProxy() : bool
170+
{
171+
return $this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, 'initializeProxy', array());
172+
}
173+
174+
/**
175+
* {@inheritdoc}
176+
*/
177+
public function isProxyInitialized() : bool
178+
{
179+
return null !== $this->valueHolder5157dd96e88c0;
180+
}
181+
182+
/**
183+
* {@inheritdoc}
184+
*/
185+
public function getWrappedValueHolderValue()
186+
{
187+
return $this->valueHolder5157dd96e88c0;
188+
}
189+
}

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) {%w$container = $this;%wreturn $this->services[\'foo\'] = new '
72+
'%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] =%s'
7373
.'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction '
7474
.'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {'
7575
.'%w$wrappedInstance = $container->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.3.9",
2020
"symfony/dependency-injection": "~2.8|~3.0.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.3|~3.0.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