Skip to content

Commit fdbf36b

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [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
2 parents ebfefb9 + 97d734f commit fdbf36b

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@
183183
"Symfony\\Bridge\\PsrHttpMessage\\": "src/Symfony/Bridge/PsrHttpMessage/",
184184
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
185185
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
186-
"Symfony\\Component\\": "src/Symfony/Component/"
186+
"Symfony\\Component\\": "src/Symfony/Component/",
187+
"Symfony\\Runtime\\Symfony\\Component\\": "src/Symfony/Component/Runtime/Internal/"
187188
},
188189
"files": [
189190
"src/Symfony/Component/String/Resources/functions.php"
@@ -192,7 +193,8 @@
192193
"src/Symfony/Component/Cache/Traits/ValueWrapper.php"
193194
],
194195
"exclude-from-classmap": [
195-
"**/Tests/"
196+
"**/Tests/",
197+
"**/bin/"
196198
]
197199
},
198200
"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/Mime/Part/TextPart.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ public function getName(): ?string
123123
public function getBody(): string
124124
{
125125
if ($this->body instanceof File) {
126-
return file_get_contents($this->body->getPath());
126+
if (false === $ret = @file_get_contents($this->body->getPath())) {
127+
throw new InvalidArgumentException(error_get_last()['message']);
128+
}
129+
130+
return $ret;
127131
}
128132

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

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Mime\Tests\Part;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mime\Exception\InvalidArgumentException;
1516
use Symfony\Component\Mime\Header\Headers;
1617
use Symfony\Component\Mime\Header\ParameterizedHeader;
1718
use Symfony\Component\Mime\Header\UnstructuredHeader;
@@ -55,6 +56,16 @@ public function testConstructorWithFile()
5556
$this->assertSame('content', implode('', iterator_to_array($p->bodyToIterable())));
5657
}
5758

59+
public function testConstructorWithUnknownFile()
60+
{
61+
$p = new TextPart(new File(\dirname(__DIR__).'/Fixtures/unknown.txt'));
62+
63+
// Exception should be thrown only when the body is accessed
64+
$this->expectException(InvalidArgumentException::class);
65+
$this->expectExceptionMessageMatches('{Failed to open stream}');
66+
$p->getBody();
67+
}
68+
5869
public function testConstructorWithNonStringOrResource()
5970
{
6071
$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
@@ -54,7 +54,8 @@
5454
"autoload": {
5555
"psr-4": { "Symfony\\Component\\Validator\\": "" },
5656
"exclude-from-classmap": [
57-
"/Tests/"
57+
"/Tests/",
58+
"/Resources/bin/"
5859
]
5960
},
6061
"minimum-stability": "dev"

0 commit comments

Comments
 (0)