diff --git a/composer.json b/composer.json index 008375cfbe7ec..98ff6c774ce12 100644 --- a/composer.json +++ b/composer.json @@ -183,7 +183,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" @@ -192,7 +193,8 @@ "src/Symfony/Component/Cache/Traits/ValueWrapper.php" ], "exclude-from-classmap": [ - "**/Tests/" + "**/Tests/", + "**/bin/" ] }, "autoload-dev": { diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 3fa0f8dc517da..1283dfe33a9b0 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -32,7 +32,8 @@ "files": [ "bootstrap.php" ], "psr-4": { "Symfony\\Bridge\\PhpUnit\\": "" }, "exclude-from-classmap": [ - "/Tests/" + "/Tests/", + "/bin/" ] }, "bin": [ diff --git a/src/Symfony/Component/Mime/Part/TextPart.php b/src/Symfony/Component/Mime/Part/TextPart.php index a13300955e36c..1054c25e46f9b 100644 --- a/src/Symfony/Component/Mime/Part/TextPart.php +++ b/src/Symfony/Component/Mime/Part/TextPart.php @@ -123,7 +123,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) { diff --git a/src/Symfony/Component/Mime/Tests/Part/TextPartTest.php b/src/Symfony/Component/Mime/Tests/Part/TextPartTest.php index 905349e670048..ae1a5921ecc1e 100644 --- a/src/Symfony/Component/Mime/Tests/Part/TextPartTest.php +++ b/src/Symfony/Component/Mime/Tests/Part/TextPartTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Mime\Tests\Part; use PHPUnit\Framework\TestCase; +use Symfony\Component\Mime\Exception\InvalidArgumentException; use Symfony\Component\Mime\Header\Headers; use Symfony\Component\Mime\Header\ParameterizedHeader; use Symfony\Component\Mime\Header\UnstructuredHeader; @@ -55,6 +56,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); diff --git a/src/Symfony/Component/Scheduler/Schedule.php b/src/Symfony/Component/Scheduler/Schedule.php index 4ccd88ff7a6e9..bd413892bc671 100644 --- a/src/Symfony/Component/Scheduler/Schedule.php +++ b/src/Symfony/Component/Scheduler/Schedule.php @@ -141,6 +141,10 @@ 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; @@ -148,6 +152,10 @@ public function before(callable $listener, int $priority = 0): static 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; @@ -155,6 +163,10 @@ public function after(callable $listener, int $priority = 0): static 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; diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 4f55dd2d1f827..1076a74854453 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -54,7 +54,8 @@ "autoload": { "psr-4": { "Symfony\\Component\\Validator\\": "" }, "exclude-from-classmap": [ - "/Tests/" + "/Tests/", + "/Resources/bin/" ] }, "minimum-stability": "dev"