Skip to content

Commit

Permalink
Add use input to the pattern function
Browse files Browse the repository at this point in the history
  • Loading branch information
JoMessina committed Apr 25, 2024
1 parent 6055372 commit d4cb395
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ExpressionLanguage/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
4 changes: 2 additions & 2 deletions src/ExpressionLanguage/TemporaryFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public function __construct(string $name)
$name,
function (string $value): string {
$pattern = <<<'PHP'
(function ($data) {
(function ($data) use ($input) {
if (!is_string($data)) {
return null;
}
$stream = fopen('php://temp', 'r+');
fwrite($stream, $data);
fseek($stream, 0, SEEK_SET);
return $stream;
})(%s);
})(%s)
PHP;

return sprintf($pattern, $value);
Expand Down

0 comments on commit d4cb395

Please sign in to comment.