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

Skip to content

Commit 9a0422c

Browse files
Merge branch '2.8' into 3.4
* 2.8: PropertyInfo\DoctrineExtractor - There is bug when indexBy is meta key [minor] SCA
2 parents 939a42f + 8c5fe44 commit 9a0422c

File tree

11 files changed

+40
-13
lines changed

11 files changed

+40
-13
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

B422 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/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/Component/Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function getInputOptionData(InputOption $option)
121121
{
122122
return array(
123123
'name' => '--'.$option->getName(),
124-
'shortcut' => $option->getS 10000 hortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '',
124+
'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
125125
'accept_value' => $option->acceptValue(),
126126
'is_value_required' => $option->isValueRequired(),
127127
'is_multiple' => $option->isArray(),

src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function describeInputOption(InputOption $option, array $options = arr
7070
{
7171
$name = '--'.$option->getName();
7272
if ($option->getShortcut()) {
73-
$name .= '|-'.implode('|-', explode('|', $option->getShortcut())).'';
73+
$name .= '|-'.str_replace('|', '|-', $option->getShortcut()).'';
7474
}
7575

7676
$this->write(

src/Symfony/Component/Console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ private function getInputOptionDocument(InputOption $option)
224224
$pos = strpos($option->getShortcut(), '|');
225225
if (false !== $pos) {
226226
$objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
227-
$objectXML->setAttribute('shortcuts', '-'.implode('|-', explode('|', $option->getShortcut())));
227+
$objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
228228
} else {
229229
$objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
230230
}

src/Symfony/Component/Console/Input/InputOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function getDescription()
195195
*
196196
* @return bool
197197
*/
198-
public function equals(InputOption $option)
198+
public function equals(self $option)
199199
{
200200
return $option->getName() === $this->getName()
201201
&& $option->getShortcut() === $this->getShortcut()

src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ public function hasMetadataFor($value)
160160

161161
$class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
162162

163-
if (class_exists($class) || interface_exists($class)) {
164-
return true;
165-
}
166-
167-
return false;
163+
return class_exists($class) || interface_exists($class, false);
168164
}
169165
}

0 commit comments

Comments
 (0)
0