Skip to content

Commit

Permalink
Merge branch '7.1' into 7.2
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fabpot committed Jun 2, 2024
2 parents 1fdb01b + be2ab50 commit 02d5fce
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
"Symfony\\Bridge\\PsrHttpMessage\\": "src/Symfony/Bridge/PsrHttpMessage/",
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
"Symfony\\Component\\": "src/Symfony/Component/"
"Symfony\\Component\\": "src/Symfony/Component/",
"Symfony\\Runtime\\Symfony\\Component\\": "src/Symfony/Component/Runtime/Internal/"
},
"files": [
"src/Symfony/Component/String/Resources/functions.php"
Expand All @@ -193,7 +194,8 @@
"src/Symfony/Component/Cache/Traits/ValueWrapper.php"
],
"exclude-from-classmap": [
"**/Tests/"
"**/Tests/",
"**/bin/"
]
},
"autoload-dev": {
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Bridge/PhpUnit/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"files": [ "bootstrap.php" ],
"psr-4": { "Symfony\\Bridge\\PhpUnit\\": "" },
"exclude-from-classmap": [
"/Tests/"
"/Tests/",
"/bin/"
]
},
"bin": [
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Emoji/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"psr-4": { "Symfony\\Component\\Emoji\\": "" },
"exclude-from-classmap": [
"/Tests/",
"/Resources/data/"
"/Resources/data/",
"/Resources/bin/"
]
},
"minimum-stability": "dev"
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Mime/Part/TextPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ public function getName(): ?string
public function getBody(): string
{
if ($this->body instanceof File) {
return file_get_contents($this->body->getPath());
if (false === $ret = @file_get_contents($this->body->getPath())) {
throw new InvalidArgumentException(error_get_last()['message']);
}

return $ret;
}

if (null === $this->seekable) {
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Mime/Tests/Part/TextPartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ public function testConstructorWithFile()
$this->assertSame('content', implode('', iterator_to_array($p->bodyToIterable())));
}

public function testConstructorWithUnknownFile()
{
$p = new TextPart(new File(\dirname(__DIR__).'/Fixtures/unknown.txt'));

// Exception should be thrown only when the body is accessed
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('{Failed to open stream}');
$p->getBody();
}

public function testConstructorWithNonStringOrResource()
{
$this->expectException(\TypeError::class);
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/Scheduler/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,32 @@ public function getSchedule(): static

public function before(callable $listener, int $priority = 0): static
{
if (!$this->dispatcher) {
throw new LogicException(sprintf('To register a listener with "%s()", you need to set an event dispatcher on the Schedule.', __METHOD__));
}

$this->dispatcher->addListener(PreRunEvent::class, $listener, $priority);

return $this;
}

public function after(callable $listener, int $priority = 0): static
{
if (!$this->dispatcher) {
throw new LogicException(sprintf('To register a listener with "%s()", you need to set an event dispatcher on the Schedule.', __METHOD__));
}

$this->dispatcher->addListener(PostRunEvent::class, $listener, $priority);

return $this;
}

public function onFailure(callable $listener, int $priority = 0): static
{
if (!$this->dispatcher) {
throw new LogicException(sprintf('To register a listener with "%s()", you need to set an event dispatcher on the Schedule.', __METHOD__));
}

$this->dispatcher->addListener(FailureEvent::class, $listener, $priority);

return $this;
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Validator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"autoload": {
"psr-4": { "Symfony\\Component\\Validator\\": "" },
"exclude-from-classmap": [
"/Tests/"
"/Tests/",
"/Resources/bin/"
]
},
"minimum-stability": "dev"
Expand Down

0 comments on commit 02d5fce

Please sign in to comment.