Skip to content

Commit 02d5fce

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: [Scheduler] Throw an exception when no dispatcher has been passed to a Schedule [Mime] Fix TextPart using an unknown File Fix autoload configs to avoid warnings when building optimized autoloaders Fix autoload configs to avoid warnings when building optimized autoloaders
2 parents 1fdb01b + be2ab50 commit 02d5fce

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@
184184
"Symfony\\Bridge\\PsrHttpMessage\\": "src/Symfony/Bridge/PsrHttpMessage/",
185185
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
186186
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
187-
"Symfony\\Component\\": "src/Symfony/Component/"
187+
"Symfony\\Component\\": "src/Symfony/Component/",
188+
"Symfony\\Runtime\\Symfony\\Component\\": "src/Symfony/Component/Runtime/Internal/"
188189
},
189190
"files": [
190191
"src/Symfony/Component/String/Resources/functions.php"
@@ -193,7 +194,8 @@
193194
"src/Symfony/Component/Cache/Traits/ValueWrapper.php"
194195
],
195196
"exclude-from-classmap": [
196-
"**/Tests/"
197+
"**/Tests/",
198+
"**/bin/"
197199
]
198200
},
199201
"autoload-dev": {

src/Symfony/Bridge/PhpUnit/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"files": [ "bootstrap.php" ],
3333
"psr-4": { "Symfony\\Bridge\\PhpUnit\\": "" },
3434
"exclude-from-classmap": [
35-
"/Tests/"
35+
"/Tests/",
36+
"/bin/"
3637
]
3738
},
3839
"bin": [

src/Symfony/Component/Emoji/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"psr-4": { "Symfony\\Component\\Emoji\\": "" },
2929
"exclude-from-classmap": [
3030
"/Tests/",
31-
"/Resources/data/"
31+
"/Resources/data/",
32+
"/Resources/bin/"
3233
]
3334
},
3435
"minimum-stability": "dev"

src/Symfony/Component/Mime/Part/TextPart.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ public function getName(): ?string
125125
public function getBody(): string
126126
{
127127
if ($this->body instanceof File) {
128-
return file_get_contents($this->body->getPath());
128+
if (false === $ret = @file_get_contents($this->body->getPath())) {
129+
throw new InvalidArgumentException(error_get_last()['message']);
130+
}
131+
132+
return $ret;
129133
}
130134

131135
if (null === $this->seekable) {

src/Symfony/Component/Mime/Tests/Part/TextPartTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public function testConstructorWithFile()
5858
$this->assertSame('content', implode('', iterator_to_array($p->bodyToIterable())));
5959
}
6060

61+
public function testConstructorWithUnknownFile()
62+
{
63+
$p = new TextPart(new File(\dirname(__DIR__).'/Fixtures/unknown.txt'));
64+
65+
// Exception should be thrown only when the body is accessed
66+
$this->expectException(InvalidArgumentException::class);
67+
$this->expectExceptionMessageMatches('{Failed to open stream}');
68+
$p->getBody();
69+
}
70+
6171
public function testConstructorWithNonStringOrResource()
6272
{
6373
$this->expectException(\TypeError::class);

src/Symfony/Component/Scheduler/Schedule.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,32 @@ public function getSchedule(): static
141141

142142
public function before(callable $listener, int $priority = 0): static
143143
{
144+
if (!$this->dispatcher) {
145+
throw new LogicException(sprintf('To register a listener with "%s()", you need to set an event dispatcher on the Schedule.', __METHOD__));
146+
}
147+
144148
$this->dispatcher->addListener(PreRunEvent::class, $listener, $priority);
145149

146150
return $this;
147151
}
148152

149153
public function after(callable $listener, int $priority = 0): static
150154
{
155+
if (!$this->dispatcher) {
156+
throw new LogicException(sprintf('To register a listener with "%s()", you need to set an event dispatcher on the Schedule.', __METHOD__));
157+
}
158+
151159
$this->dispatcher->addListener(PostRunEvent::class, $listener, $priority);
152160

153161
return $this;
154162
}
155163

156164
public function onFailure(callable $listener, int $priority = 0): static
157165
{
166+
if (!$this->dispatcher) {
167+
throw new LogicException(sprintf('To register a listener with "%s()", you need to set an event dispatcher on the Schedule.', __METHOD__));
168+
}
169+
158170
$this->dispatcher->addListener(FailureEvent::class, $listener, $priority);
159171

160172
return $this;

src/Symfony/Component/Validator/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"autoload": {
5757
"psr-4": { "Symfony\\Component\\Validator\\": "" },
5858
"exclude-from-classmap": [
59-
"/Tests/"
59+
"/Tests/",
60+
"/Resources/bin/"
6061
]
6162
},
6263
"minimum-stability": "dev"

0 commit comments

Comments
 (0)