8000 Merge branch '4.3' into 4.4 · symfony/symfony@a0c2aa8 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a0c2aa8

Browse files
Merge branch '4.3' into 4.4
* 4.3: Fix inconsistent return points. pass translation parameters to the trans filter [Mime] fixed wrong mimetype [ProxyManagerBridge] Polyfill for unmaintained version [HttpClient] Declare `$active` first to prevent weird issue Remove deprecated assertContains [HttpClient] fix tests SCA: dropped unused mocks, duplicate import and a function alias usage Added correct plural for box -> boxes [Config] fix test Fix remaining tests Improve fa (persian) translation
2 parents d94c4b4 + b406466 commit a0c2aa8

File tree

85 files changed

+433
-182
lines changed

Some content is hidden

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

85 files changed

+433
-182
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@
139139
"Symfony\\Component\\": "src/Symfony/Component/"
140140
},
141141
"classmap": [
142-
"src/Symfony/Component/Intl/Resources/stubs"
142+
"src/Symfony/Component/Intl/Resources/stubs",
143+
"src/Symfony/Bridge/ProxyManager/Legacy/ProxiedMethodReturnExpression.php"
143144
],
144145
"exclude-from-classmap": [
145146
"**/Tests/"

src/Symfony/Bridge/Monolog/Logger.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,7 @@ private function getDebugLogger()
113113
return $handler;
114114
}
115115
}
116+
117+
return null;
116118
}
117119
}

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function testLegacyTestMethodIsDetectedAsSuch()
4646
public function testItCanBeConvertedToAString()
4747
{
4848
$deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__);
49-
$this->assertContains('💩', $deprecation->toString());
50-
$this->assertContains(__FUNCTION__, $deprecation->toString());
49+
$this->assertStringContainsString('💩', $deprecation->toString());
50+
$this->assertStringContainsString(__FUNCTION__, $deprecation->toString());
5151
}
5252

5353
public function testItRulesOutFilesOutsideVendorsAsIndirect()

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public function getProxyCode(Definition $definition)
9494
);
9595
}
9696

97+
if (version_compare(self::getProxyManagerVersion(), '2.5', '<')) {
98+
$code = str_replace(' \Closure::bind(function ', ' \Closure::bind(static function ', $code);
99+
}
100+
97101
return $code;
98102
}
99103

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/*
3+
* This file is part of the Symfony package.
4+
*
5+
* (c) Fabien Potencier <fabien@symfony.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace ProxyManager\Generator\Util;
12+
13+
use Composer\Autoload\ClassLoader;
14+
use ProxyManager\Version;
15+
16+
if (class_exists(Version::class) && version_compare(\defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion(), '2.5', '<')) {
17+
/**
18+
* Utility class to generate return expressions in method, given a method signature.
19+
*
20+
* This is required since return expressions may be forbidden by the method signature (void).
21+
*
22+
* @author Marco Pivetta <ocramius@gmail.com>
23+
* @license MIT
24+
*
25+
* @see https://github.com/Ocramius/ProxyManager
26+
*/
27+
final class ProxiedMethodReturnExpression
28+
{
29+
public static function generate(string $returnedValueExpression, ?\ReflectionMethod $originalMethod): string
30+
{
31+
$originalReturnType = null === $originalMethod ? null : $originalMethod->getReturnType();
32+
33+
$originalReturnTypeName = null === $originalReturnType ? null : $originalReturnType->getName();
34+
35+
if ('void' === $originalReturnTypeName) {
36+
return $returnedValueExpression.";\nreturn;";
37+
}
38+
39+
return 'return '.$returnedValueExpression.';';
40+
}
41+
}
42+
} else {
43+
// Fallback to the original class by unregistering this file from composer class loader
44+
$getComposerClassLoader = static function ($functionLoader) use (&$getComposerClassLoader) {
45+
if (\is_array($functionLoader)) {
46+
$functionLoader = $functionLoader[0];
47+
}
48+
if (!\is_object($functionLoader)) {
49+
return;
50+
}
51+
if ($functionLoader instanceof ClassLoader) {
52+
return $functionLoader;
53+
}
54+
if ($functionLoader instanceof \Symfony\Component\Debug\DebugClassLoader) {
55+
return $getComposerClassLoader($functionLoader->getClassLoader());
56+
}
57+
if ($functionLoader instanceof \Symfony\Component\ErrorHandler\DebugClassLoader) {
58+
return $getComposerClassLoader($functionLoader->getClassLoader());
59+
}
60+
};
61+
62+
$classLoader = null;
63+
$functions = spl_autoload_functions();
64+
while (null === $classLoader && $functions) {
65+
$classLoader = $getComposerClassLoader(array_shift($functions));
66+
}
67+
$getComposerClassLoader = null;
68+
69+
if (null !== $classLoader) {
70+
$classLoader->addClassMap([ProxiedMethodReturnExpression::class => null]);
71+
$classLoader->loadClass(ProxiedMethodReturnExpression::class);
72+
}
73+
}

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use ProxyManager\Version;
1516
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
1617
use Symfony\Component\DependencyInjection\Definition;
1718
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
@@ -59,6 +60,20 @@ public function testGetProxyCode()
5960
);
6061
}
6162

63+
public function testStaticBinding()
64+
{
65+
if (!class_exists(Version::class) || version_compare(\defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion(), '2.1', '<')) {
66+
$this->markTestSkipped('ProxyManager prior to version 2.1 does not support static binding');
67+
}
68+
69+
$definition = new Definition(__CLASS__);
70+
$definition->setLazy(true);
71+
72+
$code = $this->dumper->getProxyCode($definition);
73+
74+
$this->assertStringContainsString('\Closure::bind(static function (\PHPUnit\Framework\TestCase $instance) {', $code);
75+
}
76+
6277
public function testDeterministicProxyCode()
6378
{
6479
$definition = new Definition(__CLASS__);

src/Symfony/Bridge/ProxyManager/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"autoload": {
3030
"psr-4": { "Symfony\\Bridge\\ProxyManager\\": "" },
31+
"classmap": [ "Legacy/ProxiedMethodReturnExpression.php" ],
3132
"exclude-from-classmap": [
3233
"/Tests/"
3334
]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
{%- endif -%}
100100
{%- endif -%}
101101
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
102-
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
102+
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain)) -}}
103103
</label>
104104
{%- endif -%}
105105
{%- endblock checkbox_radio_label %}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266

267267
{{ widget|raw }}
268268
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
269-
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
269+
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain)) -}}
270270
{{- form_errors(form) -}}
271271
</label>
272272
{%- endif -%}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
{% endif %}
267267
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
268268
{{ widget|raw }}
269-
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
269+
{{ translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain) }}
270270
</label>
271271
{%- endblock checkbox_radio_label %}
272272

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
225225
->canBeEnabled()
226226
->beforeNormalization()
227227
->always(function ($v) {
228-
if (true === $v['enabled']) {
228+
if (\is_array($v) && true === $v['enabled']) {
229229
$workflows = $v;
230230
unset($workflows['enabled']);
231231

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testCommandWithValidKey()
4545
$tester = $this->getCommandTester($this->getKernel());
4646
$tester->execute(['pool' => 'foo', 'key' => 'bar']);
4747

48-
$this->assertContains('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay());
48+
$this->assertStringContainsString('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay());
4949
}
5050

5151
public function testCommandWithInValidKey()
@@ -62,7 +62,7 @@ public function testCommandWithInValidKey()
6262
$tester = $this->getCommandTester($this->getKernel());
6363
$tester->execute(['pool' => 'foo', 'key' => 'bar']);
6464

65-
$this->assertContains('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay());
65+
$this->assertStringContainsString('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay());
6666
}
6767

6868
public function testCommandDeleteFailed()

src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testLintFilesFromBundleDirectory()
6969
);
7070

7171
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
72-
$this->assertContains('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
72+
$this->assertStringContainsString('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
7373
}
7474

7575
/**

src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd()
226226
$this->assertSame(0, $tester->getStatusCode());
227227
$display = explode('Lists commands', $tester->getDisplay());
228228

229-
$this->assertContains(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));
229+
$this->assertStringContainsString(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));
230230
}
231231

232232
public function testSuggestingPackagesWithExactMatch()

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolListCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function testListPools()
3131
$tester->execute([]);
3232

3333
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success');
34-
$this->assertContains('cache.app', $tester->getDisplay());
35-
$this->assertContains('cache.system', $tester->getDisplay());
34+
$this->assertStringContainsString('cache.app', $tester->getDisplay());
35+
$this->assertStringContainsString('cache.system', $tester->getDisplay());
3636
}
3737

3838
public function testEmptyList()

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testDumpWithPrefixedEnv()
7171
$tester = $this->createCommandTester();
7272
$tester->execute(['name' => 'FrameworkBundle']);
7373

74-
$this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
74+
$this->assertStringContainsString("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
7575
}
7676

7777
/**

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ public function testPrivateAlias()
5757

5858
$tester = new ApplicationTester($application);
5959
$tester->run(['command' => 'debug:container', '--show-hidden' => true]);
60-
$this->assertNotContains('public', $tester->getDisplay());
61-
$this->assertNotContains('private_alias', $tester->getDisplay());
60+
$this->assertStringNotContainsString('public', $tester->getDisplay());
61+
$this->assertStringNotContainsString('private_alias', $tester->getDisplay());
6262

6363
$tester->run(['command' => 'debug:container']);
64-
$this->assertContains('public', $tester->getDisplay());
65-
$this->assertContains('private_alias', $tester->getDisplay());
64+
$this->assertStringContainsString('public', $tester->getDisplay());
65+
$this->assertStringContainsString('private_alias', $tester->getDisplay());
6666

6767
$tester->run(['command' => 'debug:container', 'name' => 'private_alias']);
68-
$this->assertContains('The "private_alias" service or alias has been removed', $tester->getDisplay());
68+
$this->assertStringContainsString('The "private_alias" service or alias has been removed', $tester->getDisplay());
6969
}
7070

7171
/**
@@ -133,7 +133,7 @@ public function testDescribeEnvVar()
133133
$tester = new ApplicationTester($application);
134134
$tester->run(['command' => 'debug:container', '--env-var' => 'js'], ['decorated' => false]);
135135

136-
$this->assertContains(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
136+
$this->assertStringContainsString(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
137137
}
138138

139139
public function provideIgnoreBackslashWhenFindingService()

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testSearchIgnoreBackslashWhenFindingService()
5656

5757
$tester = new ApplicationTester($application);
5858
$tester->run(['command' => 'debug:autowiring', 'search' => 'HttpKernelHttpKernelInterface']);
59-
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
59+
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
6060
}
6161

6262
public function testSearchNoResults()
@@ -83,7 +83,7 @@ public function testSearchNotAliasedService()
8383
$tester = new ApplicationTester($application);
8484
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect']);
8585

86-
$this->assertContains(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
86+
$this->assertStringContainsString(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
8787
}
8888

8989
public function testSearchNotAliasedServiceWithAll()
@@ -95,6 +95,6 @@ public function testSearchNotAliasedServiceWithAll()
9595

9696
$tester = new ApplicationTester($application);
9797
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
98-
$this->assertContains('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
98+
$this->assertStringContainsString('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
9999
}
100100
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function testDumpAllRoutes()
3434
$display = $tester->getDisplay();
3535

3636
$this->assertSame(0, $ret, 'Returns 0 in case of success');
37-
$this->assertContains('routerdebug_test', $display);
38-
$this->assertContains('/test', $display);
39-
$this->assertContains('/session', $display);
37+
$this->assertStringContainsString('routerdebug_test', $display);
38+
$this->assertStringContainsString('/test', $display);
39+
$this->assertStringContainsString('/session', $display);
4040
}
4141

4242
public function testDumpOneRoute()
@@ -45,8 +45,8 @@ public function testDumpOneRoute()
4545
$ret = $tester->execute(['name' => 'routerdebug_session_welcome']);
4646

4747
$this->assertSame(0, $ret, 'Returns 0 in case of success');
48-
$this->assertContains('routerdebug_session_welcome', $tester->getDisplay());
49-
$this->assertContains('/session', $tester->getDisplay());
48+
$this->assertStringContainsString('routerdebug_session_welcome', $tester->getDisplay());
49+
$this->assertStringContainsString('/session', $tester->getDisplay());
5050
}
5151

5252
public function testSearchMultipleRoutes()
@@ -56,9 +56,9 @@ public function testSearchMultipleRoutes()
5656
$ret = $tester->execute(['name' => 'routerdebug'], ['interactive' => true]);
5757

5858
$this->assertSame(0, $ret, 'Returns 0 in case of success');
59-
$this->assertContains('Select one of the matching routes:', $tester->getDisplay());
60-
$this->assertContains('routerdebug_test', $tester->getDisplay());
61-
$this->assertContains('/test', $tester->getDisplay());
59+
$this->assertStringContainsString('Select one of the matching routes:', $tester->getDisplay());
60+
$this->assertStringContainsString('routerdebug_test', $tester->getDisplay());
61+
$this->assertStringContainsString('/test', $tester->getDisplay());
6262
}
6363

6464
public function testSearchWithThrow()

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TranslationDebugCommandTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ public function testDumpAllTrans()
3333
$ret = $tester->execute(['locale' => 'en']);
3434

3535
$this->assertSame(0, $ret, 'Returns 0 in case of success');
36-
$this->assertContains('missing messages hello_from_construct_arg_service', $tester->getDisplay());
37-
$this->assertContains('missing messages hello_from_subscriber_service', $tester->getDisplay());
38-
$this->assertContains('missing messages hello_from_property_service', $tester->getDisplay());
39-
$this->assertContains('missing messages hello_from_method_calls_service', $tester->getDisplay());
40-
$this->assertContains('missing messages hello_from_controller', $tester->getDisplay());
41-
$this->assertContains('unused validators This value should be blank.', $tester->getDisplay());
42-
$this->assertContains('unused security Invalid CSRF token.', $tester->getDisplay());
36+
$this->assertStringContainsString('missing messages hello_from_construct_arg_service', $tester->getDisplay());
37+
$this->assertStringContainsString('missing messages hello_from_subscriber_service', $tester->getDisplay());
38+
$this->assertStringContainsString('missing messages hello_from_property_service', $tester->getDisplay());
39+
$this->assertStringContainsString('missing messages hello_from_method_calls_service', $tester->getDisplay());
40+
$this->assertStringContainsString('missing messages hello_from_controller', $tester->getDisplay());
41+
$this->assertStringContainsString('unused validators This value should be blank.', $tester->getDisplay());
42+
$this->assertStringContainsString('unused security Invalid CSRF token.', $tester->getDisplay());
4343
}
4444

4545
private function createCommandTester(): CommandTester

src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ public function getFirewallConfig(Request $request)
5454
$context = $this->getFirewallContext($request);
5555

5656
if (null === $context) {
57-
return;
57+
return null;
5858
}
5959

6060
return $context->getConfig();
6161
}
6262

6363
/**
64-
* @return FirewallContext
64+
* @return FirewallContext|null
6565
*/
6666
private function getFirewallContext(Request $request)
6767
{
@@ -83,5 +83,7 @@ private function getFirewallContext(Request $request)
8383
return $this->container->get($contextId);
8484
}
8585
}
86+
87+
return null;
8688
}
8789
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function testEncodePasswordNative()
109109
], ['interactive' => false]);
110110

111111
$output = $this->passwordEncoderCommandTester->getDisplay();
112-
$this->assertContains('Password encoding succeeded', $output);
112+
$this->assertStringContainsString('Password encoding succeeded', $output);
113113

114114
$encoder = new NativePasswordEncoder();
115115
preg_match('# Encoded password\s{1,}([\w+\/$.,=]+={0,2})\s+#', $output, $matches);
@@ -130,7 +130,7 @@ public function testEncodePasswordSodium()
130130
], ['interactive' => false]);
131131

132132
$output = $this->passwordEncoderCommandTester->getDisplay();
133-
$this->assertContains('Password encoding succeeded', $output);
133+
$this->assertStringContainsString('Password encoding succeeded', $output);
134134

135135
preg_match('# Encoded password\s+(\$?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
136136
$hash = $matches[1];

0 commit comments

Comments
 (0)
0