comparison vendor/psy/psysh/src/Output/ProcOutputPager.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 5fb285c0d0e3
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
49 * @throws \RuntimeException When unable to write output (should never happen) 49 * @throws \RuntimeException When unable to write output (should never happen)
50 */ 50 */
51 public function doWrite($message, $newline) 51 public function doWrite($message, $newline)
52 { 52 {
53 $pipe = $this->getPipe(); 53 $pipe = $this->getPipe();
54 if (false === @fwrite($pipe, $message . ($newline ? PHP_EOL : ''))) { 54 if (false === @\fwrite($pipe, $message . ($newline ? PHP_EOL : ''))) {
55 // @codeCoverageIgnoreStart 55 // @codeCoverageIgnoreStart
56 // should never happen 56 // should never happen
57 throw new \RuntimeException('Unable to write output'); 57 throw new \RuntimeException('Unable to write output');
58 // @codeCoverageIgnoreEnd 58 // @codeCoverageIgnoreEnd
59 } 59 }
60 60
61 fflush($pipe); 61 \fflush($pipe);
62 } 62 }
63 63
64 /** 64 /**
65 * Close the current pager process. 65 * Close the current pager process.
66 */ 66 */
67 public function close() 67 public function close()
68 { 68 {
69 if (isset($this->pipe)) { 69 if (isset($this->pipe)) {
70 fclose($this->pipe); 70 \fclose($this->pipe);
71 } 71 }
72 72
73 if (isset($this->proc)) { 73 if (isset($this->proc)) {
74 $exit = proc_close($this->proc); 74 $exit = \proc_close($this->proc);
75 if ($exit !== 0) { 75 if ($exit !== 0) {
76 throw new \RuntimeException('Error closing output stream'); 76 throw new \RuntimeException('Error closing output stream');
77 } 77 }
78 } 78 }
79 79
86 * If no active pager process exists, fork one and return its input pipe. 86 * If no active pager process exists, fork one and return its input pipe.
87 */ 87 */
88 private function getPipe() 88 private function getPipe()
89 { 89 {
90 if (!isset($this->pipe) || !isset($this->proc)) { 90 if (!isset($this->pipe) || !isset($this->proc)) {
91 $desc = [['pipe', 'r'], $this->stream, fopen('php://stderr', 'w')]; 91 $desc = [['pipe', 'r'], $this->stream, \fopen('php://stderr', 'w')];
92 $this->proc = proc_open($this->cmd, $desc, $pipes); 92 $this->proc = \proc_open($this->cmd, $desc, $pipes);
93 93
94 if (!is_resource($this->proc)) { 94 if (!\is_resource($this->proc)) {
95 throw new \RuntimeException('Error opening output stream'); 95 throw new \RuntimeException('Error opening output stream');
96 } 96 }
97 97
98 $this->pipe = $pipes[0]; 98 $this->pipe = $pipes[0];
99 } 99 }