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

Skip to content

Commit af6be35

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Config] Handle nullable node name + fix inheritdocs [Security] added userChecker to SimpleAuthenticationProvider [Debug] fix test Fix typo in test method name Fixes #26563 (open_basedir restriction in effect) [Debug] Reset previous exception handler ealier to prevent infinite loop add hint in Github pull request template [Validator] Fix docblock of ClassMetadata#members [BrowserKit] Fix cookie path handling when $domain is null [DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore [BrowserKit] Improves CookieJar::get [BrowserKit] Fix Cookie's PHPDoc [DomCrawler] Change bad wording in ChoiceFormField::untick [DomCrawler] Fix the PHPDoc of ChoiceFormField::setValue [DomCrawler] Avoid a useless call to strtolower [FrameworkBundle] HttpCache is not longer abstract [DomCrawler] extract(): fix a bug when the attribute list is empty [Config] Backport string|null api for node names
2 parents b0bbdef + 7323372 commit af6be35

28 files changed

+224
-138
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| Bug fix? | yes/no
55
| New feature? | yes/no <!-- don't forget to update src/**/CHANGELOG.md files -->
66
| BC breaks? | no <!-- see https://symfony.com/bc -->
7-
| Deprecations? | yes/no <!-- don't forget to update UPGRADE-*.md files -->
7+
| Deprecations? | yes/no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
88
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
99
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
1010
| License | MIT

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function guessRequired($class, $property)
9595
$classMetadata = $classMetadatas[0];
9696

9797
// Check whether the field exists and is nullable or not
98-
if ($classMetadata->hasField($property)) {
98+
if (isset($classMetadata->fieldMappings[$property])) {
9999
if (!$classMetadata->isNullable($property) && Type::BOOLEAN !== $classMetadata->getTypeOfField($property)) {
100100
return new ValueGuess(true, Guess::HIGH_CONFIDENCE);
101101
}
@@ -124,7 +124,7 @@ public 10000 function guessRequired($class, $property)
124124
public function guessMaxLength($class, $property)
125125
{
126126
$ret = $this->getMetadata($class);
127-
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
127+
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
128128
$mapping = $ret[0]->getFieldMapping($property);
129129

130130
if (isset($mapping['length'])) {
@@ -143,7 +143,7 @@ public function guessMaxLength($class, $property)
143143
public function guessPattern($class, $property)
144144
{
145145
$ret = $this->getMetadata($class);
146-
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
146+
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
147147
if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
148148
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
149149
}

src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@ public function requiredProvider()
3333

3434
// Simple field, not nullable
3535
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
36-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true));
36+
$classMetadata->fieldMappings['field'] = true;
3737
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false));
3838

3939
$return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE));
4040

4141
// Simple field, nullable
4242
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
43-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true));
43+
$classMet F987 adata->fieldMappings['field'] = true;
4444
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true));
4545

4646
$return[] = array($classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE));
4747

4848
// One-to-one, nullable (by default)
4949
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
50-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
5150
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
5251

5352
$mapping = array('joinColumns' => array(array()));
@@ -57,7 +56,6 @@ public function requiredProvider()
5756

5857
// One-to-one, nullable (explicit)
5958
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
60-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
6159
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
6260

6361
$mapping = array('joinColumns' => array(array('nullable' => true)));
@@ -67,7 +65,6 @@ public function requiredProvider()
6765

6866
// One-to-one, not nullable
6967
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
70-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
7168
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
7269

7370
$mapping = array('joinColumns' => array(array('nullable' => false)));
@@ -77,7 +74,6 @@ public function requiredProvider()
7774

7875
// One-to-many, no clue
7976
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
80-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
8177
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false));
8278

8379
$return[] = array($classMetadata, null);

src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php

+5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\HttpCache;
1313

14-
use Symfony\Component\HttpKernel\HttpKernelInterface;
14+
use Symfony\Component\HttpKernel\KernelInterface;
1515
use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache;
1616
use Symfony\Component\HttpKernel\HttpCache\Esi;
1717
use Symfony\Component\HttpKernel\HttpCache\Store;
@@ -23,16 +23,16 @@
2323
*
2424
* @author Fabien Potencier <fabien@symfony.com>
2525
*/
26-
abstract class HttpCache extends BaseHttpCache
26+
class HttpCache extends BaseHttpCache
2727
{
2828
protected $cacheDir;
2929
protected $kernel;
3030

3131
/**
32-
* @param HttpKernelInterface $kernel An HttpKernelInterface instance
33-
* @param string $cacheDir The cache directory (default used if null)
32+
* @param KernelInterface $kernel A KernelInterface instance
33+
* @param string $cacheDir The cache directory (default used if null)
3434
*/
35-
public function __construct(HttpKernelInterface $kernel, $cacheDir = null)
35+
public function __construct(KernelInterface $kernel, $cacheDir = null)
3636
{
3737
$this->kernel = $kernel;
3838
$this->cacheDir = $cacheDir;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
5555
->replaceArgument(0, new Reference($config['authenticator']))
5656
->replaceArgument(1, new Reference($userProviderId))
5757
->replaceArgument(2, $id)
58+
->replaceArgument(3, new Reference('security.user_checker.'.$id))
5859
;
5960

6061
return $provider;

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class Cookie
4444
/**
4545
* Sets a cookie.
4646
*
47-
* @param string $name The cookie name
48-
* @param string $value The value of the cookie
49-
* @param string $expires The time the cookie expires
50-
* @param string $path The path on the server in which the cookie will be available on
51-
* @param string $domain The domain that the cookie is available
52-
* @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
53-
* @param bool $httponly The cookie httponly flag
54-
* @param bool $encodedValue Whether the value is encoded or not
47+
* @param string $name The cookie name
48+
* @param string $value The value of the cookie
49+
* @param string|null $expires The time the cookie expires
50+
* @param string|null $path The path on the server in which the cookie will be available on
51+
* @param string $domain The domain that the cookie is available
52+
* @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
53+
* @param bool $httponly The cookie httponly flag
54+
* @param bool $encodedValue Whether the value is encoded or not
5555
*/
5656
public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false)
5757
{
@@ -112,8 +112,8 @@ public function __toString()
112112
/**
113113
* Creates a Cookie instance from a Set-Cookie header value.
114114
*
115-
* @param string $cookie A Set-Cookie header value
116-
* @param string $url The base URL
115+
* @param string $cookie A Set-Cookie header value
116+
* @param string|null $url The base URL
117117
*
118118
* @return static
119119
*
@@ -242,7 +242,7 @@ public function getRawValue()
242242
/**
243243
* Gets the expires time of the cookie.
244244
*
245-
* @return string The cookie expires time
245+
* @return string|null The cookie expires time
246246
*/
247247
public function getExpiresTime()
248248
{

src/Symfony/Component/BrowserKit/CookieJar.php

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,21 @@ public function get($name, $path = '/', $domain = null)
4343
{
4444
$this->flushExpiredCookies();
4545

46-
if (!empty($domain)) {
47-
foreach ($this->cookieJar as $cookieDomain => $pathCookies) {
48-
if ($cookieDomain) {
49-
$cookieDomain = '.'.ltrim($cookieDomain, '.');
50-
if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) {
51-
continue;
52-
}
53-
}
54-
55-
foreach ($pathCookies as $cookiePath => $namedCookies) {
56-
if ($cookiePath != substr($path, 0, strlen($cookiePath))) {
57-
continue;
58-
}
59-
if (isset($namedCookies[$name])) {
60-
return $namedCookies[$name];
61-
}
46+
foreach ($this->cookieJar as $cookieDomain => $pathCookies) {
47+
if ($cookieDomain && $domain) {
48+
$cookieDomain = '.'.ltrim($cookieDomain, '.');
49+
if ($cookieDomain !== substr('.'.$domain, -\strlen($cookieDomain))) {
50+
continue;
6251
}
6352
}
6453

65-
return;
66-
}
67-
68-
// avoid relying on this behavior that is mainly here for BC reasons
69-
foreach ($this->cookieJar as $cookies) {
70-
if (isset($cookies[$path][$name])) {
71-
return $cookies[$path][$name];
54+
foreach ($pathCookies as $cookiePath => $namedCookies) {
55+
if (0 !== strpos($path, $cookiePath)) {
56+
continue;
57+
}
58+
if (isset($namedCookies[$name])) {
59+
return $namedCookies[$name];
60+
}
7261
}
7362
}
7463
}

src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ public function testCookieGetWithSubdirectory()
237237
$this->assertEquals($cookie1, $cookieJar->get('foo', '/test', 'example.com'));
238238
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'example.com'));
239239
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/bar', 'example.com'));
240+
241+
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/bar'));
240242
}
241243

242244
public function testCookieWithWildcardDomain()

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,31 +153,23 @@ public function setIgnoreExtraKeys($boolean, $remove = true)
153153
}
154154

155155
/**
156-
* Sets the node Name.
157-
*
158-
* @param string $name The node's name
156+
* {@inheritdoc}
159157
*/
160158
public function setName($name)
161159
{
162160
$this->name = $name;
163161
}
164162

165163
/**
166-
* Checks if the node has a default value.
167-
*
168-
* @return bool
164+
* {@inheritdoc}
169165
*/
170166
public function hasDefaultValue()
171167
{
172168
return $this->addIfNotSet;
173169
}
174170

175171
/**
176-
* Retrieves the default value.
177-
*
178-
* @return array The default value
179-
*
180-
* @throws \RuntimeException if the node has no default value
172+
* {@inheritdoc}
181173
*/
182174
public function getDefaultValue()
183175
{

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ abstract class BaseNode implements NodeInterface
3333
protected $attributes = array();
3434

3535
/**
36-
* @param string $name The name of the node
37-
* @param NodeInterface $parent The parent of this node
36+
* @param string|null $name The name of the node
37+
* @param NodeInterface|null $parent The parent of this node
3838
*
3939
* @throws \InvalidArgumentException if the name contains a period
4040
*/
4141
public function __construct($name, NodeInterface $parent = null)
4242
{
43-
if (false !== strpos($name, '.')) {
43+
if (false !== strpos($name = (string) $name, '.')) {
4444
throw new \InvalidArgumentException('The name must not contain ".".');
4545
}
4646

@@ -170,29 +170,23 @@ public function setFinalValidationClosures(array $closures)
170170
}
171171

172172
/**
173-
* Checks if this node is required.
174-
*
175-
* @return bool
173+
* {@inheritdoc}
176174
*/
177175
public function isRequired()
178176
{
179177
return $this->required;
180178
}
181179

182180
/**
183-
* Returns the name of this node.
184-
*
185-
* @return string The Node's name
181+
* {@inheritdoc}
186182
*/
187183
public function getName()
188184
{
189185
return $this->name;
190186
}
191187

192188
/**
193-
* Retrieves the path of this node.
194-
*
195-
* @return string The Node's path
189+
* {@inheritdoc}
196190
*/
197191
public function getPath()
198192
{
@@ -206,14 +200,7 @@ public function getPath()
206200
}
207201

208202
/**
209-
* Merges two values together.
210-
*
211-
* @param mixed $leftSide
212-
* @param mixed $rightSide
213-
*
214-
* @return mixed The merged value
215-
*
216-
* @throws ForbiddenOverwriteException
203+
* {@inheritdoc}
217204
*/
218205
final public function merge($leftSide, $rightSide)
219206
{
@@ -233,11 +220,7 @@ final public function merge($leftSide, $rightSide)
233220
}
234221

235222
/**
236-
* Normalizes a value, applying all normalization closures.
237-
*
238-
* @param mixed $value Value to normalize
239-
*
240-
* @return mixed The normalized value
223+
* {@inheritdoc}
241224
*/
242225
final public function normalize($value)
243226
{
@@ -285,14 +268,7 @@ public function getParent()
285268
}
286269

287270
/**
288-
* Finalizes a value, applying all finalization closures.
289-
*
290-
* @param mixed $value The value to finalize
291-
*
292-
* @return mixed The finalized value
293-
*
294-
* @throws Exception
295-
* @throws InvalidConfigurationException
271+
* {@inheritdoc}
296272
*/
297273
final public function finalize($value)
298274
{

src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,15 @@ public function __construct($name, NodeParentInterface $parent = null)
4848
}
4949
< 10000 br>
5050
/**
51-
* Sets a custom children builder.
51+
* {@inheritdoc}
5252
*/
5353
public function setBuilder(NodeBuilder $builder)
5454
{
5555
$this->nodeBuilder = $builder;
5656
}
5757

5858
/**
59-
* Returns a builder to add children nodes.
60-
*
61-
* @return NodeBuilder
59+
* {@inheritdoc}
6260
*/
6361
public function children()
6462
{
@@ -310,17 +308,7 @@ public function normalizeKeys($bool)
310308
}
311309

312310
/**
313-
* Appends a node definition.
314-
*
315-
* $node = new ArrayNodeDefinition()
316-
* ->children()
317-
* ->scalarNode('foo')->end()
318-
* ->scalarNode('baz')->end()
319-
* ->end()
320-
* ->append($this->getBarNodeDefinition())
321-
* ;
322-
*
323-
* @return $this
311+
* {@inheritdoc}
324312
*/
325313
public function append(NodeDefinition $node)
326314
{

src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ public function end()
143143
/**
144144
* Creates a child node.
145145
*
146-
* @param string $name The name of the node
147-
* @param string $type The type of the node
146+
* @param string|null $name The name of the node
147+
* @param string $type The type of the node
148148
*
149149
* @return NodeDefinition The child node
150150
*

0 commit comments

Comments
 (0)
0