8000 Free cursor resources by jtojnar · Pull Request #77 · symfony/console · GitHub
[go: up one dir, main page]

Skip to content

Free cursor resources #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service 8000 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cursor: close php://input handle
  • Loading branch information
jtojnar committed Dec 31, 2021
commit e180e36a474bb42320a8b17693bfa9c4c06addc8
9 changes: 8 additions & 1 deletion Cursor.php
74CF
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ final class Cursor
{
private $output;
private $input;
private $inputResource = null;

/**
* @param resource|null $input
*/
public function __construct(OutputInterface $output, $input = null)
{
$this->output = $output;
$this->input = $input ?? (\defined('STDIN') ? \STDIN : fopen('php://input', 'r+'));
$this->input = $input ?? (\defined('STDIN') ? \STDIN : $this->inputResource = fopen('php://input', 'r+'));
}

/**
Expand Down Expand Up @@ -211,4 +212,10 @@ public function getCurrentPosition(): array

return [$col, $row];
}

public function __destruct() {
if ($this->inputResource !== null) {
fclose($this->inputResource);
}
}
}
0