Skip to content

Commit af9ec74

Browse files
committed
Merge branch '3.0'
* 3.0: (24 commits) [Filesystem] Better error handling in remove() [DependencyInjection] Add coverage for invalid Expression in exportParameters [DependencyInjection] Add coverage for all invalid arguments in exportParameters anonymous services are always private [Form] FormValidator removed code related to removed option [Console] Correct time formatting. [WebProfilerBundle] Fixed error from unset twig variable Force profiler toolbar svg display [DependencyInjection] Resolve aliases before removing abstract services + add tests Fix Dom Crawler select option with empty value Remove unnecessary option assignment fix tests (use non-deprecated options) remove unused variable mock the proper method [PropertyAccess] Fix regression [HttpFoundation] Improve phpdoc [Logging] Add support for firefox in ChromePhpHandler Windows 10 version check in just one line Detect CLI color support for Windows 10 build 10586 [Security] Fixed SwitchUserListener when exiting an impersonication with AnonymousToken ...
2 parents 1ca8d1c + e72d509 commit af9ec74

File tree

33 files changed

+369
-117
lines changed

33 files changed

+369
-117
lines changed

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

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,35 @@ public function getTypes($class, $property, array $context = array())
7171

7272
if ($metadata->isSingleValuedAssociation($property)) {
7373
if ($metadata instanceof ClassMetadataInfo) {
74-
$nullable = isset($metadata->discriminatorColumn['nullable']) ? $metadata->discriminatorColumn['nullable'] : false;
74+
$associationMapping = $metadata->getAssociationMapping($property);
75+
76+
$nullable = $this->isAssociationNullable($associationMapping);
7577
} else {
7678
$nullable = false;
7779
}
7880

7981
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class));
8082
}
8183

84+
$collectionKeyType = Type::BUILTIN_TYPE_INT;
85+
86+
if ($metadata instanceof ClassMetadataInfo) {
87+
$associationMapping = $metadata->getAssociationMapping($property);
88+
89+
if (isset($associationMapping['indexBy'])) {
90+
$indexProperty = $associationMapping['indexBy'];
91+
$typeOfField = $metadata->getTypeOfField($indexProperty);
92+
93+
$collectionKeyType = $this->getPhpType($typeOfField);
94+
}
95+
}
96+
8297
return array(new Type(
8398
Type::BUILTIN_TYPE_OBJECT,
8499
false,
85100
'Doctrine\Common\Collections\Collection',
86101
true,
87-
new Type(Type::BUILTIN_TYPE_INT),
102+
new Type($collectionKeyType),
88103
new Type(Type::BUILTIN_TYPE_OBJECT, false, $class)
89104
));
90105
}
@@ -118,6 +133,35 @@ public function getTypes($class, $property, array $context = array())
118133
}
119134
}
120135

136+
/**
137+
* Determines whether an association is nullable.
138+
*
139+
* @param array $associationMapping
140+
*
141+
* @return bool
142+
*
143+
* @see https://github.com/doctrine/doctrine2/blob/v2.5.4/lib/Doctrine/ORM/Tools/EntityGenerator.php#L1221-L1246
144+
*/
145+
private function isAssociationNullable(array $associationMapping)
146+
{
147+
if (isset($associationMapping['id']) && $associationMapping['id']) {
148+
return false;
149+
}
150+
151+
if (!isset($associationMapping['joinColumns'])) {
152+
return true;
153+
}
154+
155+
$joinColumns = $associationMapping['joinColumns'];
156+
foreach ($joinColumns as $joinColumn) {
157+
if (isset($joinColumn['nullable']) && !$joinColumn['nullable']) {
158+
return false;
159+
}
160+
}
161+
162+
return true;
163+
}
164+
121165
/**
122166
* Gets the corresponding built-in PHP type.
123167
*

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function testGetProperties()
5454
'customFoo',
5555
'foo',
5656
'bar',
57+
'indexedBar',
5758
),
5859
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
5960
);
@@ -75,7 +76,7 @@ public function typesProvider()
7576
array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))),
7677
array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))),
7778
array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))),
78-
array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation'))),
79+
array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation'))),
7980
array('bar', array(new Type(
8081
Type::BUILTIN_TYPE_OBJECT,
8182
false,
@@ -84,6 +85,14 @@ public function typesProvider()
8485
new Type(Type::BUILTIN_TYPE_INT),
8586
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
8687
))),
88+
array('indexedBar', array(new Type(
89+
Type::BUILTIN_TYPE_OBJECT,
90+
false,
91+
'Doctrine\Common\Collections\Collection',
92+
true,
93+
new Type(Type::BUILTIN_TYPE_STRING),
94+
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
95+
))),
8796
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
8897
array('customFoo', null),
8998
array('notMapped', null),

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class DoctrineDummy
4040
*/
4141
public $bar;
4242

43+
/**
44+
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="guid")
45+
*/
46+
protected $indexedBar;
47+
4348
/**
4449
* @Column(type="guid")
4550
*/

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
1313

1414
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Entity;
1516
use Doctrine\ORM\Mapping\Id;
1617

1718
/**
@@ -26,4 +27,9 @@ class DoctrineRelation
2627
* @Column(type="smallint")
2728
*/
2829
public $id;
30+
31+
/**
32+
* @Column(type="guid")
33+
*/
34+
protected $guid;
2935
}

src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function onKernelResponse(FilterResponseEvent $event)
4141
return;
4242
}
4343

44-
if (!preg_match('{\bChrome/\d+[\.\d+]*\b}', $event->getRequest()->headers->get('User-Agent'))) {
44+
if (!preg_match('{\b(?:Chrome/\d+(?:\.\d+)*|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}', $event->getRequest()->headers->get('User-Agent'))) {
4545
$this->sendHeaders = false;
4646
$this->headers = array();
4747

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ public static function register($mode = 0)
194194
private static function hasColorSupport()
195195
{
196196
if ('\\' === DIRECTORY_SEPARATOR) {
197-
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
197+
return
198+
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
199+
|| false !== getenv('ANSICON')
200+
|| 'ON' === getenv('ConEmuANSI')
201+
|| 'xterm' === getenv('TERM');
198202
}
199203

200204
return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function configure()
7777
7878
<info>php %command.full_name% --parameters</info>
7979
80-
Display a specific parameter by specifying his name with the <info>--parameter</info> option:
80+
Display a specific parameter by specifying its name with the <info>--parameter</info> option:
8181
8282
<info>php %command.full_name% --parameter=kernel.debug</info>
8383

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,24 @@
5050
</span>
5151
</div>
5252

53-
{% if 'n/a' != collector.appname %}
53+
{% if 'n/a' is not same as(collector.appname) %}
5454
<div class="sf-toolbar-info-piece">
5555
<b>Kernel name</b>
5656
<span>{{ collector.appname }}</span>
5757
</div>
5858
{% endif %}
5959

60-
{% if 'n/a' != collector.env %}
60+
{% if 'n/a' is not same as(collector.env) %}
6161
<div class="sf-toolbar-info-piece">
6262
<b>Environment</b>
6363
<span>{{ collector.env }}</span>
6464
</div>
6565
{% endif %}
6666

67-
{% if 'n/a' != collector.debug %}
67+
{% if 'n/a' is not same as(collector.debug) %}
6868
<div class="sf-toolbar-info-piece">
6969
<b>Debug</b>
70-
<span class="{{ debug_status_class }}">{{ collector.debug ? 'enabled' : 'disabled' }}</span>
70+
<span class="sf-toolbar-status sf-toolbar-status-{{ collector.debug ? 'green' : 'red' }}">{{ collector.debug ? 'enabled' : 'disabled' }}</span>
7171
</div>
7272
{% endif %}
7373
</div>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
.sf-toolbarreset svg,
6060
.sf-toolbarreset img {
6161
height: 20px;
62+
display: inline-block;
6263
}
6364

6465
.sf-toolbarreset .hide-button {

src/Symfony/Component/Console/Helper/Helper.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,28 @@ public static function formatTime($secs)
6262
{
6363
static $timeFormats = array(
6464
array(0, '< 1 sec'),
65-
array(2, '1 sec'),
66-
array(59, 'secs', 1),
65+
array(1, '1 sec'),
66+
array(2, 'secs', 1),
6767
array(60, '1 min'),
68-
array(3600, 'mins', 60),
69-
array(5400, '1 hr'),
70-
array(86400, 'hrs', 3600),
71-
array(129600, '1 day'),
72-
array(604800, 'days', 86400),
68+
array(120, 'mins', 60),
69+
array(3600, '1 hr'),
70+
array(7200, 'hrs', 3600),
71+
array(86400, '1 day'),
72+
array(172800, 'days', 86400),
7373
);
7474

75-
foreach ($timeFormats as $format) {
75+
foreach ($timeFormats as $index => $format) {
7676
if ($secs >= $format[0]) {
77-
continue;
77+
if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
78+
|| $index == count($timeFormats) - 1
79+
) {
80+
if (2 == count($format)) {
81+
return $format[1];
82+
}
83+
84+
return floor($secs / $format[2]).' '.$format[1];
85+
}
7886
}
79-
80-
if (2 == count($format)) {
81-
return $format[1];
82-
}
83-
84-
return ceil($secs / $format[2]).' '.$format[1];
8587
}
8688
}
8789

0 commit comments

Comments
 (0)