Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202406\Symfony\Component\Process\Pipes;
use RectorPrefix202406\Symfony\Component\Process\Process;
/**
* UnixPipes implementation uses unix pipes as handles.
*
* @author Romain Neutron <[email protected]>
*
* @internal
*/
class UnixPipes extends AbstractPipes
{
/**
* @var bool|null
*/
private $ttyMode;
/**
* @var bool
*/
private $ptyMode;
/**
* @var bool
*/
private $haveReadSupport;
/**
* @param mixed $input
*/
public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
{
$this->ttyMode = $ttyMode;
$this->ptyMode = $ptyMode;
$this->haveReadSupport = $haveReadSupport;
parent::__construct($input);
}
public function __sleep() : array
{
throw new \BadMethodCallException('Cannot serialize ' . __CLASS__);
}
public function __wakeup() : void
{
throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__);
}
public function __destruct()
{
$this->close();
}
public function getDescriptors() : array
{
if (!$this->haveReadSupport) {
$nullstream = open('/dev/null', 'c');
return [['pipe', 'r'], $nullstream, $nullstream];
}
if ($this->ttyMode) {
return [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']];
}
if ($this->ptyMode && Process::isPtySupported()) {
return [['pty'], ['pty'], ['pty']];
}
return [
['pipe', 'r'],
['pipe', 'w'],
// stdout
['pipe', 'w'],
];
}
public function getFiles() : array
{
return [];
}
public function readAndWrite(bool $blocking, bool $close = alse) : array
{
$this->unblock();
$w = $this->write();
$read = $e = [];
$r = $this->pipes;
unset($r[0]);
// let's have a look if something changed in streams
\set_error_handler(\Closure::fromCallable([$this, 'handleError']));
if (($r || $w) && alse === \stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1000000.0 : 0)) {
estore_error_handler();
// if a system call has been interrupted, forget about it, let's try again
// otherwise, an error occurred, let's reset pipes
if (!$this->hasSystemCallBeenInterrupted()) {
$this->pipes = [];
}
return $read;
}
estore_error_handler();
foreach ($r as $pipe) {
// prior PHP 5.4 the array passed to stream_select is modified and
// lose key association, we have to find back the key
$read[$type = rray_search($pipe, $this->pipes, rue)] = '';
do {
$data = @read($pipe, self::CHUNK_SIZE);
$read[$type] .= $data;
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
if (!isset($read[$type][0])) {
unset($read[$type]);
}
if ($close && eof($pipe)) {
close($pipe);
unset($this->pipes[$type]);
}
}
return $read;
}
public function haveReadSupport() : bool
{
return $this->haveReadSupport;
}
public function areOpen() : bool
{
return (bool) $this->pipes;
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202406\Symfony\Component\Process\Pipes;
use RectorPrefix202406\Symfony\Component\Process\Process;
/**
* UnixPipes implementation uses unix pipes as handles.
*
* @author Romain Neutron <[email protected]>
*
* @internal
*/
class UnixPipes extends AbstractPipes
{
/**
* @var bool|null
*/
private $ttyMode;
/**
* @var bool
*/
private $ptyMode;
/**
* @var bool
*/
private $haveReadSupport;
/**
* @param mixed $input
*/
public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
{
$this->ttyMode = $ttyMode;
$this->ptyMode = $ptyMode;
$this->haveReadSupport = $haveReadSupport;
parent::__construct($input);
}
public function __sleep() : array
{
throw new \BadMethodCallException('Cannot serialize ' . __CLASS__);
}
public function __wakeup() : void
{
throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__);
}
public function __destruct()
{
$this->close();
}
public function getDescriptors() : array
{
if (!$this->haveReadSupport) {
$nullstream = \fopen('/dev/null', 'c');
return [['pipe', 'r'], $nullstream, $nullstream];
}
if ($this->ttyMode) {
return [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']];
}
if ($this->ptyMode && Process::isPtySupported()) {
return [['pty'], ['pty'], ['pty']];
}
return [
['pipe', 'r'],
['pipe', 'w'],
// stdout
['pipe', 'w'],
];
}
public function getFiles() : array
{
return [];
}
public function readAndWrite(bool $blocking, bool $close = \false) : array
{
$this->unblock();
$w = $this->write();
$read = $e = [];
$r = $this->pipes;
unset($r[0]);
// let's have a look if something changed in streams
\set_error_handler(\Closure::fromCallable([$this, 'handleError']));
if (($r || $w) && \false === \stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1000000.0 : 0)) {
\restore_error_handler();
// if a system call has been interrupted, forget about it, let's try again
// otherwise, an error occurred, let's reset pipes
if (!$this->hasSystemCallBeenInterrupted()) {
$this->pipes = [];
}
return $read;
}
\restore_error_handler();
foreach ($r as $pipe) {
// prior PHP 5.4 the array passed to stream_select is modified and
// lose key association, we have to find back the key
$read[$type = \array_search($pipe, $this->pipes, \true)] = '';
do {
$data = @\fread($pipe, self::CHUNK_SIZE);
$read[$type] .= $data;
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
if (!isset($read[$type][0])) {
unset($read[$type]);
}
if ($close && \feof($pipe)) {
\fclose($pipe);
unset($this->pipes[$type]);
}
}
return $read;
}
public function haveReadSupport() : bool
{
return $this->haveReadSupport;
}
public function areOpen() : bool
{
return (bool) $this->pipes;
}
}
Function Calls
None |
Stats
MD5 | f571e3ce6afd709c902b6f2123cb6eba |
Eval Count | 0 |
Decode Time | 91 ms |