Skip to content

Commit 3373e19

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Remove extra space in NotificationEmail Fix the usage of the Valid constraints in array-based forms [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 ace115c + 5236c15 commit 3373e19

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
$attributeOptIn = false;
4141

4242
if (\PHP_VERSION_ID >= 80000) {
@@ -106,7 +106,7 @@ public function setContainer(ContainerInterface $container)
106106
{
107107
$this->container = $container;
108108

109-
if (\is_callable(['parent', __FUNCTION__])) {
109+
if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
110110
return parent::setContainer($container);
111111
}
112112

Tests/Service/ServiceSubscriberTraitTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ public function testSetContainerIsCalledOnParent()
5555
$this->assertSame($container, (new TestService())->setContainer($container));
5656
}
5757

58+
public function testParentNotCalledIfHasMagicCall()
59+
{
60+
$container = new class([]) implements ContainerInterface {
61+
use ServiceLocatorTrait;
62+
};
63+
$service = new class() extends ParentWithMagicCall {
64+
use ServiceSubscriberTrait;
65+
};
66+
67+
$this->assertNull($service->setContainer($container));
68+
$this->assertSame([], $service::getSubscribedServices());
69+
}
70+
71+
public function testParentNotCalledIfNoParent()
72+
{
73+
$container = new class([]) implements ContainerInterface {
74+
use ServiceLocatorTrait;
75+
};
76+
$service = new class() {
77+
use ServiceSubscriberTrait;
78+
};
79+
80+
$this->assertNull($service->setContainer($container));
81+
$this->assertSame([], $service::getSubscribedServices());
82+
}
83+
5884
/**
5985
* @requires PHP 8
6086
* @group legacy
@@ -118,6 +144,19 @@ public function aChildService(): Service3
118144
}
119145
}
120146

147+
class ParentWithMagicCall
148+
{
149+
public function __call($method, $args)
150+
{
151+
throw new \BadMethodCallException('Should not be called.');
152+
}
153+
154+
public static function __callStatic($method, $args)
155+
{
156+
throw new \BadMethodCallException('Should not be called.');
157+
}
158+
}
159+
121160
class Service3
122161
{
123162
}

0 commit comments

Comments
 (0)