Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b1c03a

Browse files
Merge branch '4.0'
* 4.0: Fix tests PropertyInfo\DoctrineExtractor - There is bug when indexBy is meta key Fix PercentType error rendering. [minor] SCA [Cache] Inline some hot function calls fixed Silex project's URL fixed deprecations in tests fixed Twig URL [Cache] Add missing `@internal` tag on ProxyTrait fix formatting arguments in plaintext format Fix PSR exception context key Don't assume that file binary exists on *nix OS Fix that ESI/SSI processing can turn a \"private\" response \"public\" [Form] Fixed trimming choice values fix rendering exception stack traces [Routing] Fix loading multiple class annotations for invokable classes
2 parents 48f0afc + 6d9d329 commit 1b1c03a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+433
-122
lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,19 @@ public function getTypes($class, $property, array $context = array())
9595

9696
if (isset($associationMapping['indexBy'])) {
9797
$indexProperty = $associationMapping['indexBy'];
98+
/** @var ClassMetadataInfo $subMetadata */
9899
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
99100
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
100101

102+
if (null === $typeOfField) {
103+
$associationMapping = $subMetadata->getAssociationMapping($indexProperty);
104+
105+
/** @var ClassMetadataInfo $subMetadata */
106+
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($indexProperty);
107+
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
108+
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
109+
}
110+
101111
$collectionKeyType = $this->getPhpType($typeOfField);
102112
}
103113
}

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function testGetProperties()
6161
'foo',
6262
'bar',
6363
'indexedBar',
64+
'indexedFoo',
6465
),
6566
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
6667
);
@@ -141,6 +142,14 @@ public function typesProvider()
141142
new Type(Type::BUILTIN_TYPE_STRING),
142143
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
143144
))),
145+
array('indexedFoo', array(new Type(
146+
Type::BUILTIN_TYPE_OBJECT,
147+
false,
148+
'Doctrine\Common\Collections\Collection',
149+
true,
150+
new Type(Type::BUILTIN_TYPE_STRING),
151+
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
152+
))),
144153
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
145154
array('customFoo', null),
146155
array('notMapped', null),

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\ORM\Mapping\Column;
1515
use Doctrine\ORM\Mapping\Entity;
1616
use Doctrine\ORM\Mapping\Id;
17+
use Doctrine\ORM\Mapping\OneToMany;
1718
use Doctrine\ORM\Mapping\ManyToMany;
1819
use Doctrine\ORM\Mapping\ManyToOne;
1920

@@ -45,6 +46,11 @@ class DoctrineDummy
4546
*/
4647
protected $indexedBar;
4748

49+
/**
50+
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="foo", indexBy="foo")
51+
*/
52+
protected $indexedFoo;
53+
4854
/**
4955
* @Column(type="guid")
5056
*/

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\ORM\Mapping\Column;
1515
use Doctrine\ORM\Mapping\Entity;
1616
use Doctrine\ORM\Mapping\Id;
17+
use Doctrine\ORM\Mapping\ManyToOne;
1718

1819
/**
1920
* @Entity
@@ -32,4 +33,10 @@ class DoctrineRelation
3233
* @Column(type="guid")
3334
*/
3435
protected $rguid;
36+
37+
/**
38+
* @Column(type="guid")
39+
* @ManyToOne(targetEntity="DoctrineDummy", inversedBy="indexedFoo")
40+
*/
41+
protected $foo;
3542
}

src/Symfony/Bridge/Twig/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Twig Bridge
22
===========
33

4-
Provides integration for [Twig](http://twig.sensiolabs.org/) with various
4+
Provides integration for [Twig](https://twig.symfony.com/) with various
55
Symfony components.
66

77
Resources

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@
106106
{%- endblock dateinterval_widget %}
107107

108108
{% block percent_widget -%}
109-
<div class="input-group{{ not valid ? ' form-control is-invalid' }}">
110-
{% set valid = true %}
109+
<div class="input-group">
111110
{{- block('form_widget_simple') -}}
112111
<div class="input-group-append">
113112
<span class="input-group-text">%</span>

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ private function findTemplatesInFolder($dir)
9797
private function findTemplatesInBundle(BundleInterface $bundle)
9898
{
9999
$name = $bundle->getName();
100-
$templates = array_merge(
100+
$templates = array_unique(array_merge(
101101
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
102102
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
103-
);
104-
$templates = array_unique($templates);
103+
));
105104

106105
foreach ($templates as $i => $template) {
107106
$templates[$i] = $template->set('bundle', $name);

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function formatFile($file, $line, $text = null)
157157
$file = trim($file);
158158
$fileStr = $file;
159159
if (0 === strpos($fileStr, $this->rootDir)) {
160-
$fileStr = str_replace($this->rootDir, '', str_replace('\\', '/', $fileStr));
160+
$fileStr = str_replace(array('\\', $this->rootDir), array('/', ''), $fileStr);
161161
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
162162
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
163163
}

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.txt.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% if trace.function %}
2-
at {{ trace.class ~ trace.type ~ trace.function }}({{ trace.args|format_args }})
2+
at {{ trace.class ~ trace.type ~ trace.function }}({{ trace.args|format_args_as_text }})
33
{%- endif -%}
44
{% if trace.file|default('') is not empty and trace.line|default('') is not empty %}
55
{{- trace.function ? '\n (' : 'at '}}{{ trace.file|format_file(trace.line)|striptags|replace({ (' at line ' ~ trace.line): '' }) }}:{{ trace.line }}{{ trace.function ? ')' }}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{% if exception.trace|length %}
2-
<pre class="stacktrace">
32
{{ exception.class }}:
43
{% if exception.message is not empty %}
54
{{- exception.message }}
@@ -8,5 +7,4 @@
87
{% for trace in exception.trace %}
98
{{ include('@Twig/Exception/trace.txt.twig', { trace: trace }, with_context = false) }}
109
{% endfor %}
11-
</pre>
1210
{% endif %}

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces_text.html.twig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
<tbody id="trace-text-{{ index }}">
1818
<tr>
1919
<td>
20-
{{ include('@Twig/Exception/traces.txt.twig', { exception: exception }, with_context = false) }}
20+
{% if exception.trace|length %}
21+
<pre class="stacktrace">
22+
{%- filter escape('html') -%}
23+
{{- include('@Twig/Exception/traces.txt.twig', { exception: exception, format: 'html' }, with_context = false) }}
24+
{% endfilter %}
25+
</pre>
26+
{% endif %}
2127
</td>
2228
</tr>
2329
</tbody>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<b>Resources</b>
101101
<span>
102102
{% if 'Silex' == collector.applicationname %}
103-
<a href="http://silex.sensiolabs.org/documentation" rel="help">
103+
<a href="https://silex.symfony.com/documentation" rel="help">
104104
Read Silex Docs
105105
</a>
106106
{% else %}

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function commit()
233233
if (true === $e || array() === $e) {
234234
continue;
235235
}
236-
if (is_array($e) || 1 === count($values)) {
236+
if (\is_array($e) || 1 === \count($values)) {
237237
foreach (is_array($e) ? $e : array_keys($values) as $id) {
238238
$ok = false;
239239
$v = $values[$id];

src/Symfony/Component/Cache/Adapter/ChainAdapter.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableIn
3030
{
3131
private $adapters = array();
3232
private $adapterCount;
33-
private $saveUp;
33+
private $syncItem;
3434

3535
/**
36-
* @param CacheItemPoolInterface[] $adapters The ordered list of adapters used to fetch cached items
37-
* @param int $maxLifetime The max lifetime of items propagated from lower adapters to upper ones
36+
* @param CacheItemPoolInterface[] $adapters The ordered list of adapters used to fetch cached items
37+
* @param int $defaultLifetime The default lifetime of items propagated from lower adapters to upper ones
3838
*/
39-
public function __construct(array $adapters, int $maxLifetime = 0)
39+
public function __construct(array $adapters, int $defaultLifetime = 0)
4040
{
4141
if (!$adapters) {
4242
throw new InvalidArgumentException('At least one adapter must be specified.');
@@ -55,16 +55,20 @@ public function __construct(array $adapters, int $maxLifetime = 0)
5555
}
5656
$this->adapterCount = count($this->adapters);
5757

58-
$this->saveUp = \Closure::bind(
59-
function ($adapter, $item) use ($maxLifetime) {
60-
$origDefaultLifetime = $item->defaultLifetime;
58+
$this->syncItem = \Closure::bind(
59+
function ($sourceItem, $item) use ($defaultLifetime) {
60+
$item->value = $sourceItem->value;
61+
$item->expiry = $sourceItem->expiry;
62+
$item->isHit = $sourceItem->isHit;
6163

62-
if (0 < $maxLifetime && ($origDefaultLifetime <= 0 || $maxLifetime < $origDefaultLifetime)) {
63-
$item->defaultLifetime = $maxLifetime;
64+
if (0 < $sourceItem->defaultLifetime && $sourceItem->defaultLifetime < $defaultLifetime) {
65+
$defaultLifetime = $sourceItem->defaultLifetime;
66+
}
67+
if (0 < $defaultLifetime && ($item->defaultLifetime <= 0 || $defaultLifetime < $item->defaultLifetime)) {
68+
$item->defaultLifetime = $defaultLifetime;
6469
}
6570

66-
$adapter->save($item);
67-
$item->defaultLifetime = $origDefaultLifetime;
71+
return $item;
6872
},
6973
null,
7074
CacheItem::class
@@ -76,18 +80,21 @@ function ($adapter, $item) use ($maxLifetime) {
7680
*/
7781
public function getItem($key)
7882
{
79-
$saveUp = $this->saveUp;
83+
$syncItem = $this->syncItem;
84+
$misses = array();
8085

8186
foreach ($this->adapters as $i => $adapter) {
8287
$item = $adapter->getItem($key);
8388

8489
if ($item->isHit()) {
8590
while (0 <= --$i) {
86-
$saveUp($this->adapters[$i], $item);
91+
$this->adapters[$i]->save($syncItem($item, $misses[$i]));
8792
}
8893

8994
return $item;
9095
}
96+
97+
$misses[$i] = $item;
9198
}
9299

93100
return $item;
@@ -104,6 +111,7 @@ public function getItems(array $keys = array())
104111
private function generateItems($items, $adapterIndex)
105112
{
106113
$missing = array();
114+
$misses = array();
107115
$nextAdapterIndex = $adapterIndex + 1;
108116
$nextAdapter = isset($this->adapters[$nextAdapterIndex]) ? $this->adapters[$nextAdapterIndex] : null;
109117

@@ -112,17 +120,18 @@ private function generateItems($items, $adapterIndex)
112120
yield $k => $item;
113121
} else {
114122
$missing[] = $k;
123+
$misses[$k] = $item;
115124
}
116125
}
117126

118127
if ($missing) {
119-
$saveUp = $this->saveUp;
128+
$syncItem = $this->syncItem;
120129
$adapter = $this->adapters[$adapterIndex];
121130
$items = $this->generateItems($nextAdapter->getItems($missing), $nextAdapterIndex);
122131

123132
foreach ($items as $k => $item) {
124133
if ($item->isHit()) {
125-
$saveUp($adapter, $item);
134+
$adapter->save($syncItem($item, $misses[$k]));
126135
}
127136

128137
yield $k => $item;

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function create($file, CacheItemPoolInterface $fallbackPool)
8282
*/
8383
public function getItem($key)
8484
{
85-
if (!is_string($key)) {
85+
if (!\is_string($key)) {
8686
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
8787
}
8888
if (null === $this->values) {
@@ -97,7 +97,7 @@ public function getItem($key)
9797

9898
if ('N;' === $value) {
9999
$value = null;
100-
} elseif (is_string($value) && isset($value[2]) && ':' === $value[1]) {
100+
} elseif (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
101101
try {
102102
$e = null;
103103
$value = unserialize($value);
@@ -121,7 +121,7 @@ public function getItem($key)
121121
public function getItems(array $keys = array())
122122
{
123123
foreach ($keys as $key) {
124-
if (!is_string($key)) {
124+
if (!\is_string($key)) {
125125
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
126126
}
127127
}
@@ -137,7 +137,7 @@ public function getItems(array $keys = array())
137137
*/
138138
public function hasItem($key)
139139
{
140-
if (!is_string($key)) {
140+
if (!\is_string($key)) {
141141
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
142142
}
143143
if (null === $this->values) {
@@ -152,7 +152,7 @@ public function hasItem($key)
152152
*/
153153
public function deleteItem($key)
154154
{
155-
if (!is_string($key)) {
155+
if (!\is_string($key)) {
156156
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
157157
}
158158
if (null === $this->values) {
@@ -171,7 +171,7 @@ public function deleteItems(array $keys)
171171
$fallbackKeys = array();
172172

173173
foreach ($keys as $key) {
174-
if (!is_string($key)) {
174+
if (!\is_string($key)) {
175175
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
176176
}
177177

@@ -235,7 +235,7 @@ private function generateItems(array $keys): \Generator
235235

236236
if ('N;' === $value) {
237237
yield $key => $f($key, null, true);
238-
} elseif (is_string($value) && isset($value[2]) && ':' === $value[1]) {
238+
} elseif (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
239239
try {
240240
yield $key => $f($key, unserialize($value), true);
241241
} catch (\Error $e) {

src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function (AdapterInterface $tagsAdapter, array $tags) {
107107
public function invalidateTags(array $tags)
108108
{
109109
foreach ($tags as $k => $tag) {
110-
if ('' !== $tag && is_string($tag)) {
110+
if ('' !== $tag && \is_string($tag)) {
111111
$tags[$k] = $tag.static::TAGS_PREFIX;
112112
}
113113
}
@@ -161,7 +161,7 @@ public function getItems(array $keys = array())
161161
$tagKeys = array();
162162

163163
foreach ($keys as $key) {
164-
if ('' !== $key && is_string($key)) {
164+
if ('' !== $key && \is_string($key)) {
165165
$key = static::TAGS_PREFIX.$key;
166166
$tagKeys[$key] = $key;
167167
}
@@ -202,7 +202,7 @@ public function deleteItem($key)
202202
public function deleteItems(array $keys)
203203
{
204204
foreach ($keys as $key) {
205-
if ('' !== $key && is_string($key)) {
205+
if ('' !== $key && \is_string($key)) {
206206
$keys[] = static::TAGS_PREFIX.$key;
207207
}
208208
}

0 commit comments

Comments
 (0)