Skip to content

Commit f74917e

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Make FormErrorIterator generic [symfony/mailjet-mailer] Fix invalid mailjet error managment typehint of DkimOptions algorithm wrong Remove extra space in NotificationEmail Fix the usage of the Valid constraints in array-based forms Fix return value of `NullToken::getUser()` [DI] fix `ServiceSubscriberTrait` bug where parent has `__call()` [HttpClient] Fix reading proxy settings from dotenv when curl is used [Process] Don't return executable directories in PhpExecutableFinder Center icons vertically in trace list
2 parents 50cb40c + 3373e19 commit f74917e

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

HttpClient/Test/HttpClientTestCase.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,16 @@ public function testProxy()
954954

955955
$body = $response->toArray();
956956
$this->assertSame('Basic Zm9vOmI9YXI=', $body['HTTP_PROXY_AUTHORIZATION']);
957+
958+
$_SERVER['http_proxy'] = 'http://localhost:8057';
959+
try {
960+
$response = $client->request('GET', 'http://localhost:8057/');
961+
$body = $response->toArray();
962+
$this->assertSame('localhost:8057', $body['HTTP_HOST']);
963+
$this->assertMatchesRegularExpression('#^http://(localhost|127\.0\.0\.1):8057/$#', $body['REQUEST_URI']);
964+
} finally {
965+
unset($_SERVER['http_proxy']);
966+
}
957967
}
958968

959969
public function testNoProxy()

Service/ServiceSubscriberTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function getSubscribedServices(): array
3636
return $services;
3737
}
3838

39-
$services = \is_callable(['parent', __FUNCTION__]) ? parent::getSubscribedServices() : [];
39+
$services = method_exists(get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : [];
4040

4141
foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
4242
if (self::class !== $method->getDeclaringClass()->name) {
@@ -74,7 +74,7 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
7474
{
7575
$this->container = $container;
7676

77-
if (\is_callable(['parent', __FUNCTION__])) {
77+
if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
7878
return parent::setContainer($container);
7979
}
8080

Tests/Service/ServiceSubscriberTraitTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,32 @@ public function testSetContainerIsCalledOnParent()
4040

4141
$this->assertSame($container, (new TestService())->setContainer($container));
4242
}
43+
44+
public function testParentNotCalledIfHasMagicCall()
45+
{
46+
$container = new class([]) implements ContainerInterface {
47+
use ServiceLocatorTrait;
48+
};
49+
$service = new class() extends ParentWithMagicCall {
50+
use ServiceSubscriberTrait;
51+
};
52+
53+
$this->assertNull($service->setContainer($container));
54+
$this->assertSame([], $service::getSubscribedServices());
55+
}
56+
57+
public function testParentNotCalledIfNoParent()
58+
{
59+
$container = new class([]) implements ContainerInterface {
60+
use ServiceLocatorTrait;
61+
};
62+
$service = new class() {
63+
use ServiceSubscriberTrait;
64+
};
65+
66+
$this->assertNull($service->setContainer($container));
67+
$this->assertSame([], $service::getSubscribedServices());
68+
}
4369
}
4470

4571
class ParentTestService
@@ -77,6 +103,19 @@ public function aChildService(): Service3
77103
}
78104
}
79105

106+
class ParentWithMagicCall
107+
{
108+
public function __call($method, $args)
109+
{
110+
throw new \BadMethodCallException('Should not be called.');
111+
}
112+
113+
public static function __callStatic($method, $args)
114+
{
115+
throw new \BadMethodCallException('Should not be called.');
116+
}
117+
}
118+
80119
class Service3
81120
{
82121
}

0 commit comments

Comments
 (0)