From d4cb39522f51e1f90fc593caebcfc1a314faf1db Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 25 Apr 2024 16:38:08 +0200 Subject: [PATCH] Add use input to the pattern function --- src/ExpressionLanguage/File.php | 2 +- src/ExpressionLanguage/TemporaryFile.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ExpressionLanguage/File.php b/src/ExpressionLanguage/File.php index 4031df18..7ac8daf9 100644 --- a/src/ExpressionLanguage/File.php +++ b/src/ExpressionLanguage/File.php @@ -14,7 +14,7 @@ public function __construct(string $name) $name, function (string $value): string { $pattern = <<<'PHP' - (function () { + (function () use ($input) { $resource = \tmpfile(); if ($resource === false) { throw new \RuntimeException('Could not open temporary file.'); diff --git a/src/ExpressionLanguage/TemporaryFile.php b/src/ExpressionLanguage/TemporaryFile.php index a771c42f..949606ba 100644 --- a/src/ExpressionLanguage/TemporaryFile.php +++ b/src/ExpressionLanguage/TemporaryFile.php @@ -14,7 +14,7 @@ public function __construct(string $name) $name, function (string $value): string { $pattern = <<<'PHP' - (function ($data) { + (function ($data) use ($input) { if (!is_string($data)) { return null; } @@ -22,7 +22,7 @@ function (string $value): string { fwrite($stream, $data); fseek($stream, 0, SEEK_SET); return $stream; - })(%s); + })(%s) PHP; return sprintf($pattern, $value);