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

Skip to content

Commit 4ce5a1b

Browse files
Merge branch '3.4' into 4.0
* 3.4: Add color support for Hyper terminal . [HttpFoundation] Fix tests: new message for status 425 [Doctrine Bridge] Fixed usage of wrong variable when tagged subscriber is invalid [PropertyInfo] added handling of nullable types in PhpDoc [HttpKernel] Make AbstractTestSessionListener compatible with CookieClearingLogoutHandler [Cache] provider does not respect option maxIdLength with versioning enabled
2 parents cfde207 + 771c22b commit 4ce5a1b

File tree

16 files changed

+127
-14
lines changed

16 files changed

+127
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
},
102102
"conflict": {
103103
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
104-
"phpdocumentor/type-resolver": "<0.2.1",
104+
"phpdocumentor/type-resolver": "<0.3.0",
105105
"phpunit/phpunit": "<5.4.3"
106106
},
107107
"provide": {

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function addTaggedSubscribers(ContainerBuilder $container)
6868
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
6969
foreach ($connections as $con) {
7070
if (!isset($this->connections[$con])) {
71-
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $taggedSubscriber, implode(', ', array_keys($this->connections))));
71+
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
7272
}
7373

7474
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', array(new Reference($id)));

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ private static function hasColorSupport()
316316
&& sapi_windows_vt100_support(STDOUT))
317317
|| false !== getenv('ANSICON')
318318
|| 'ON' === getenv('ConEmuANSI')
319-
|| 'xterm' === getenv('TERM');
319+
|| 'xterm' === getenv('TERM')
320+
|| 'Hyper' === getenv('TERM_PROGRAM');
320321
}
321322

322323
if (function_exists('stream_isatty')) {

src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,34 @@ public function testLongKey()
3434
$cache->hasItem(str_repeat('-', 39));
3535
}
3636

37+
public function testLongKeyVersioning()
38+
{
39+
$cache = $this->getMockBuilder(MaxIdLengthAdapter::class)
40+
->setConstructorArgs(array(str_repeat('-', 26)))
41+
->getMock();
42+
43+
$reflectionClass = new \ReflectionClass(AbstractAdapter::class);
44+
45+
$reflectionMethod = $reflectionClass->getMethod('getId');
46+
$reflectionMethod->setAccessible(true);
47+
48+
// No versioning enabled
49+
$this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12))));
50+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))));
51+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 23)))));
52+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 40)))));
53+
54+
$reflectionProperty = $reflectionClass->getProperty('versioningIsEnabled');
55+
$reflectionProperty->setAccessible(true);
56+
$reflectionProperty->setValue($cache, true);
57+
58+
// Versioning enabled
59+
$this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12))));
60+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))));
61+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 23)))));
62+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 40)))));
63+
}
64+
3765
/**
3866
* @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException
3967
* @expectedExceptionMessage Namespace must be 26 chars max, 40 given ("----------------------------------------")

src/Symfony/Component/Cache/Traits/AbstractTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private function getId($key)
255255
return $this->namespace.$this->namespaceVersion.$key;
256256
}
257257
if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) {
258-
$id = $this->namespace.$this->namespaceVersion.substr_replace(base64_encode(hash('sha256', $key, true)), ':', -22);
258+
$id = $this->namespace.$this->namespaceVersion.substr_replace(base64_encode(hash('sha256', $key, true)), ':', -(\strlen($this->namespaceVersion) + 22));
259259
}
260260

261261
return $id;

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ protected function hasColorSupport()
9898
&& @sapi_windows_vt100_support($this->stream))
9999
|| false !== getenv('ANSICON')
100100
|| 'ON' === getenv('ConEmuANSI')
101-
|| 'xterm' === getenv('TERM');
101+
|| 'xterm' === getenv('TERM')
102+
|| 'Hyper' === getenv('TERM_PROGRAM');
102103
}
103104

104105
if (function_exists('stream_isatty')) {

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function createProgressBar($max = 0)
269269
{
270270
$progressBar = parent::createProgressBar($max);
271271

272-
if ('\\' !== DIRECTORY_SEPARATOR) {
272+
if ('\\' !== DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
273273
$progressBar->setEmptyBarCharacter(''); // light shade character \u2591
274274
$progressBar->setProgressCharacter('');
275275
$progressBar->setBarCharacter(''); // dark shade character \u2593

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ class Response
6464
const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
6565
const HTTP_LOCKED = 423; // RFC4918
6666
const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
67+
68+
/**
69+
* @deprecated
70+
*/
6771
const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817
72+
const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04
6873
const HTTP_UPGRADE_REQUIRED = 426; // RFC2817
6974
const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585
7075
const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585
@@ -169,7 +174,7 @@ class Response
169174
422 => 'Unprocessable Entity', // RFC4918
170175
423 => 'Locked', // RFC4918
171176
424 => 'Failed Dependency', // RFC4918
172-
425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817
177+
425 => 'Too Early', // RFC-ietf-httpbis-replay-04
173178
426 => 'Upgrade Required', // RFC2817
174179
428 => 'Precondition Required', // RFC6585
175180
429 => 'Too Many Requests', // RFC6585

src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public function onKernelResponse(FilterResponseEvent $event)
7171

7272
if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) {
7373
$params = session_get_cookie_params();
74+
75+
foreach ($event->getResponse()->headers->getCookies() as $cookie) {
76+
if ($session->getName() === $cookie->getName() && $params['path'] === $cookie->getPath() && $params['domain'] == $cookie->getDomain()) {
77+
return;
78+
}
79+
}
80+
7481
$event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']));
7582
$this->sessionId = $session->getId();
7683
}

src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,36 @@ public function testEmptySessionWithNewSessionIdDoesSendCookie()
106106
$this->assertNotEmpty($response->headers->getCookies());
107107
}
108108

109+
/**
110+
* @dataProvider anotherCookieProvider
111+
*/
112+
public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie($existing, array $expected)
113+
{
114+
$this->sessionHasBeenStarted();
115+
$this->sessionIsEmpty();
116+
$this->fixSessionId('456');
117+
118+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
119+
$request = Request::create('/', 'GET', array(), array('MOCKSESSID' => '123'));
120+
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
121+
$this->listener->onKernelRequest($event);
122+
123+
$response = new Response('', 200, array('Set-Cookie' => $existing));
124+
125+
$response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
126+
127+
$this->assertSame($expected, $response->headers->get('Set-Cookie', null, false));
128+
}
129+
130+
public function anotherCookieProvider()
131+
{
132+
return array(
133+
'same' => array('MOCKSESSID=789; path=/', array('MOCKSESSID=789; path=/')),
134+
'different domain' => array('MOCKSESSID=789; path=/; domain=example.com', array('MOCKSESSID=789; path=/; domain=example.com', 'MOCKSESSID=456; path=/')),
135+
'different path' => array('MOCKSESSID=789; path=/foo', array('MOCKSESSID=789; path=/foo', 'MOCKSESSID=456; path=/')),
136+
);
137+
}
138+
109139
public function testUnstartedSessionIsNotSave()
110140
{
111141
$this->sessionHasNotBeenStarted();
@@ -123,10 +153,10 @@ public function testDoesNotImplementServiceSubscriberInterface()
123153
$this->assertFalse(is_subclass_of(TestSessionListener::class, ServiceSubscriberInterface::class, 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford'));
124154
}
125155

126-
private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
156+
private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, Response $response = null)
127157
{
128158
$request->setSession($this->session);
129-
$response = new Response();
159+
$response = $response ?: new Response();
130160
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
131161
$event = new FilterResponseEvent($kernel, $request, $type, $response);
132162

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public function typesProvider()
9494
array('e', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_RESOURCE))), null, null),
9595
array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null),
9696
array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null),
97+
array('h', array(new Type(Type::BUILTIN_TYPE_STRING, true)), null, null),
98+
array('i', array(new Type(Type::BUILTIN_TYPE_STRING, true), new Type(Type::BUILTIN_TYPE_INT, true)), null, null),
99+
array('j', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'DateTime')), null, null),
97100
array('donotexist', null, null, null),
98101
array('staticGetter', null, null, null),
99102
array('staticSetter', null, null, null),
@@ -130,6 +133,9 @@ public function typesWithCustomPrefixesProvider()
130133
array('e', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_RESOURCE))), null, null),
131134
array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null),
132135
array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null),
136+
array('h', array(new Type(Type::BUILTIN_TYPE_STRING, true)), null, null),
137+
array('i', array(new Type(Type::BUILTIN_TYPE_STRING, true), new Type(Type::BUILTIN_TYPE_INT, true)), null, null),
138+
array('j', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'DateTime')), null, null),
133139
array('donotexist', null, null, null),
134140
array('staticGetter', null, null, null),
135141
array('staticSetter', null, null, null),
@@ -165,6 +171,9 @@ public function typesWithNoPrefixesProvider()
165171
array('e', null, null, null),
166172
array('f', null, null, null),
167173
array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null),
174+
array('h', array(new Type(Type::BUILTIN_TYPE_STRING, true)), null, null),
175+
array('i', array(new Type(Type::BUILTIN_TYPE_STRING, true), new Type(Type::BUILTIN_TYPE_INT, true)), null, null),
176+
array('j', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'DateTime')), null, null),
168177
array('donotexist', null, null, null),
169178
array('staticGetter', null, null, null),
170179
array('staticSetter', null, null, null),

src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public function testGetProperties()
4141
'B',
4242
'Guid',
4343
'g',
44+
'h',
45+
'i',
46+
'j',
4447
'emptyVar',
4548
'foo',
4649
'foo2',
@@ -77,6 +80,9 @@ public function testGetPropertiesWithCustomPrefixes()
7780
'B',
7881
'Guid',
7982
'g',
83+
'h',
84+
'i',
85+
'j',
8086
'emptyVar',
8187
'foo',
8288
'foo2',
@@ -105,6 +111,9 @@ public function testGetPropertiesWithNoPrefixes()
105111
'B',
106112
'Guid',
107113
'g',
114+
'h',
115+
'i',
116+
'j',
108117
'emptyVar',
109118
'foo',
110119
'foo2',

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ class Dummy extends ParentDummy
6868
*/
6969
public $g;
7070

71+
/**
72+
* @var ?string
73+
*/
74+
public $h;
75+
76+
/**
77+
* @var ?string|int
78+
*/
79+
public $i;
80+
81+
/**
82+
* @var ?\DateTime
83+
*/
84+
public $j;
85+
7186
/**
7287
* This should not be removed.
7388
*

src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use phpDocumentor\Reflection\Type as DocType;
1515
use phpDocumentor\Reflection\Types\Compound;
1616
use phpDocumentor\Reflection\Types\Null_;
17+
use phpDocumentor\Reflection\Types\Nullable;
1718
use Symfony\Component\PropertyInfo\Type;
1819

1920
/**
@@ -34,6 +35,11 @@ public function getTypes(DocType $varType): array
3435
$types = array();
3536
$nullable = false;
3637

38+
if ($varType instanceof Nullable) {
39+
$nullable = true;
40+
$varType = $varType->getActualType();
41+
}
42+
3743
if (!$varType instanceof Compound) {
3844
if ($varType instanceof Null_) {
3945
$nullable = true;
@@ -54,10 +60,10 @@ public function getTypes(DocType $varType): array
5460

5561
// If null is present, all types are nullable
5662
$nullKey = array_search(Type::BUILTIN_TYPE_NULL, $varTypes);
57-
$nullable = false !== $nullKey;
63+
$nullable = $nullable || false !== $nullKey;
5864

5965
// Remove the null type from the type if other types are defined
60-
if ($nullable && count($varTypes) > 1) {
66+
if ($nullable && false !== $nullKey && count($varTypes) > 1) {
6167
unset($varTypes[$nullKey]);
6268
}
6369

src/Symfony/Component/PropertyInfo/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"conflict": {
3737
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
38-
"phpdocumentor/type-resolver": "<0.2.1",
38+
"phpdocumentor/type-resolver": "<0.3.0",
3939
"symfony/dependency-injection": "<3.4"
4040
},
4141
"suggest": {

src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ private function hasColorSupport($stream)
546546
&& @sapi_windows_vt100_support($stream))
547547
|| false !== getenv('ANSICON')
548548
|| 'ON' === getenv('ConEmuANSI')
549-
|| 'xterm' === getenv('TERM');
549+
|| 'xterm' === getenv('TERM')
550+
|| 'Hyper' === getenv('TERM_PROGRAM');
550551
}
551552

552553
if (function_exists('stream_isatty')) {
@@ -575,7 +576,8 @@ private function isWindowsTrueColor()
575576
{
576577
$result = 183 <= getenv('ANSICON_VER')
577578
|| 'ON' === getenv('ConEmuANSI')
578-
|| 'xterm' === getenv('TERM');
579+
|| 'xterm' === getenv('TERM')
580+
|| 'Hyper' === getenv('TERM_PROGRAM');
579581

580582
if (!$result && PHP_VERSION_ID >= 70200) {
581583
$version = sprintf(

0 commit comments

Comments
 (0)