Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  not registered definitions must not be modified
  fix low deps
  [String] Fix Inflector for 'hardware'
  [Mime] Use streams instead of loading raw message generator into memory
  Bump Symfony version to 7.0.9
  Update VERSION for 7.0.8
  Update CHANGELOG for 7.0.8
  Bump Symfony version to 6.4.9
  Update VERSION for 6.4.8
  Update CHANGELOG for 6.4.8
  Bump Symfony version to 5.4.41
  Update VERSION for 5.4.40
  Update CONTRIBUTORS for 5.4.40
  Update CHANGELOG for 5.4.40
  • Loading branch information
fabpot committed Jun 4, 2024
2 parents 8ada3ef + f8fd01e commit 21027ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
29 changes: 26 additions & 3 deletions RawMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,31 @@ class RawMessage
{
private bool $isGeneratorClosed;

/**
* @param iterable|string|resource $message
*/
public function __construct(
private iterable|string $message,
private $message,
) {
}

public function __destruct()
{
if (\is_resource($this->message)) {
fclose($this->message);
}
}

public function toString(): string
{
if (\is_string($this->message)) {
return $this->message;
}

if (\is_resource($this->message)) {
return stream_get_contents($this->message, -1, 0);
}

$message = '';
foreach ($this->message as $chunk) {
$message .= $chunk;
Expand All @@ -51,10 +65,19 @@ public function toIterable(): iterable
return;
}

if (\is_resource($this->message)) {
rewind($this->message);
while ($line = fgets($this->message)) {
yield $line;
}

return;
}

if ($this->message instanceof \Generator) {
$message = '';
$message = fopen('php://temp', 'w+');
foreach ($this->message as $chunk) {
$message .= $chunk;
fwrite($message, $chunk);
yield $chunk;
}
$this->isGeneratorClosed = !$this->message->valid();
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"symfony/process": "^6.4|^7.0",
"symfony/property-access": "^6.4|^7.0",
"symfony/property-info": "^6.4|^7.0",
"symfony/serializer": "^6.4|^7.0"
"symfony/serializer": "^6.4.3|^7.0.3"
},
"conflict": {
"egulias/email-validator": "~3.0.0",
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
"symfony/mailer": "<6.4",
"symfony/serializer": "<6.4"
"symfony/serializer": "<6.4.3|>7.0,<7.0.3"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Mime\\": "" },
Expand Down

0 comments on commit 21027ea

Please sign in to comment.