8000 Merge branch '5.1' · symfony/symfony@73ca97c · GitHub
[go: up one dir, main page]

Skip to content

Commit 73ca97c

Browse files
Merge branch '5.1'
* 5.1: [HttpClient] fix using proxies with NativeHttpClient [4.4] Ignore more deprecations for Mockery mocks [Routing] fix using !important and defaults/reqs in inline route definitions [ErrorHandler][DebugClassLoader] Do not check Mockery mocks classes [HttpClient] Fix using https with proxies [TwigBundle] Only remove kernel exception listener if twig is used [DI] Fix changelog Remove CHANGELOG files for 4.x Adjust expired range check Fix redis connection error message [DI] fix dumping non-shared lazy services
2 parents d0ded92 + d825513 commit 73ca97c

File tree

16 files changed

+117
-3981
lines changed

16 files changed

+117
-3981
lines changed

CHANGELOG-4.0.md

Lines changed: 0 additions & 919 deletions
This file was deleted.

CHANGELOG-4.1.md

Lines changed: 0 additions & 586 deletions
This file was deleted.

CHANGELOG-4.2.md

Lines changed: 0 additions & 668 deletions
This file was deleted.

CHANGELOG-4.3.md

Lines changed: 0 additions & 848 deletions
This file was deleted.

CHANGELOG-4.4.md

Lines changed: 0 additions & 922 deletions
This file was deleted.

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public function isHttpOnly()
306306
*/
307307
public function isExpired()
308308
{
309-
return null !== $this->expires && 0 != $this->expires && $this->expires < time();
309+
return null !== $this->expires && 0 != $this->expires && $this->expires <= time();
310310
}
311311

312312
/**

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ CHANGELOG
2727
* allowed loading and dumping tags with an attribute named "name"
2828
* deprecated `Definition::getDeprecationMessage()`, use `Definition::getDeprecation()` instead
2929
* deprecated `Alias::getDeprecationMessage()`, use `Alias::getDeprecation()` instead
30-
* deprecated PHP-DSL's `inline()` function, use `service()` instead
3130
* added support of PHP8 static return type for withers
3231
* added `AliasDeprecatedPublicServicesPass` to deprecate public services to private
3332

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,18 +863,45 @@ protected function {$methodName}($lazyInitialization)
863863
}
864864
}
865865

866-
if ($this->getProxyDumper()->isProxyCandidate($definition)) {
867-
$factoryCode = $definition->isShared() ? ($asFile ? "\$this->load('%s', false)" : '$this->%s(false)') : '$this->factories[%2$s](false)';
868-
$factoryCode = $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName, $this->doExport($id)));
866+
if (!$definition->isShared()) {
867+
$factory = sprintf('$this->factories%s[%s]', $definition->isPublic() ? '' : "['service_container']", $this->doExport($id));
868+
}
869+
870+
if ($isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition)) {
871+
if (!$definition->isShared()) {
872+
$code .= sprintf(' %s = %1$s ?? ', $factory);
873+
874+
if ($asFile) {
875+
$code .= "function () {\n";
876+
$code .= " return self::do(\$container);\n";
877+
$code .= " };\n\n";
878+
} else {
879+
$code .= sprintf("\\Closure::fromCallable([\$this, '%s']);\n\n", $methodName);
880+
}
881+
}
882+
883+
$factoryCode = $asFile ? 'self::do($container, false)' : sprintf('$this->%s(false)', $methodName);
884+
$factoryCode = $this->getProxyDumper()->getProxyFactoryCode($definition, $id, $factoryCode);
869885
$code .= $asFile ? preg_replace('/function \(([^)]*+)\) {/', 'function (\1) use ($container) {', $factoryCode) : $factoryCode;
870886
}
871887

872-
$code .= $this->addServiceInclude($id, $definition);
888+
$c = $this->addServiceInclude($id, $definition);
889+
890+
if ('' !== $c && $isProxyCandidate && !$definition->isShared()) {
891+
$c = implode("\n", array_map(function ($line) { return $line ? ' '.$line : $line; }, explode("\n", $c)));
892+
$code .= " static \$include = true;\n\n";
893+
$code .= " if (\$include) {\n";
894+
$code .= $c;
895+
$code .= " \$include = false;\n";
896+
$code .= " }\n\n";
897+
} else {
898+
$code .= $c;
899+
}
900+
873901
$c = $this->addInlineService($id, $definition);
874902

875-
if (!$definition->isShared()) {
903+
if (!$isProxyCandidate && !$definition->isShared()) {
876904
$c = implode("\n", array_map(function ($line) { return $line ? ' '.$line : $line; }, explode("\n", $c)));
877-
$factory = sprintf('$this->factories%s[%s]', $definition->isPublic() ? '' : "['service_container']", $this->doExport($id));
878905
$lazyloadInitialization = $definition->isLazy() ? '$lazyLoad = true' : '';
879906

880907
$c = sprintf(" %s = function (%s) {\n%s };\n\n return %1\$s();\n", $factory, $lazyloadInitialization, $c);

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ public function testNonSharedLazyDumpAsFiles()
307307
->setLazy(true);
308308
$container->compile();
309309
$dumper = new PhpDumper($container);
310+
$dumper->setProxyDumper(new \DummyProxyDumper());
310311
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]), true);
311312

312313
if ('\\' === \DIRECTORY_SEPARATOR) {

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ protected function getBarService()
6767
*/
6868
protected function getFooService($lazyLoad = true)
6969
{
70-
// lazy factory for stdClass
70+
$this->factories['service_container']['foo'] = $this->factories['service_container']['foo'] ?? \Closure::fromCallable([$this, 'getFooService']);
7171

72-
$this->factories['service_container']['foo'] = function ($lazyLoad = true) {
73-
return new \stdClass();
74-
};
72+
// lazy factory for stdClass
7573

76-
return $this->factories['service_container']['foo']();
74+
return new \stdClass();
7775
}
7876
}
7977

0 commit comments

Comments
 (0)
0