Get the Psy Shell readline service.

By default, this service uses (in order of preference):

* GNU Readline
* Libedit
* A transient array-based readline emulation.

@return Readline
320965
public function getReadline()
    {
        if (!isset($this->readline)) {
            $className = $this->getReadlineClass();
            $this->readline = new $className(
                $this->getHistoryFile(),
                $this->getHistorySize(),
                $this->getEraseDuplicates()
            );
        }

        return $this->readline;
    }
742456
public function current()
    {
        $leftRow = $this->leftReader->current();

        if (array_key_exists($this->nestKey, $leftRow)) {
            throw new ReaderException(
                sprintf(
                    'Left Row: "%s" Reader already contains a field named "%s". Please choose a different nest key field',
                    $this->key(),
                    $this->nestKey
                )
            );
        }
        $leftRow[$this->nestKey] = [];

        $leftId     = $this->getRowId($leftRow, $this->leftJoinField);
        $rightRow   = $this->rightReader->current();
        $rightId    = $this->getRowId($rightRow, $this->rightJoinField);

        while ($leftId == $rightId && $this->rightReader->valid()) {

            $leftRow[$this->nestKey][] = $rightRow;
            $this->rightReader->next();

            $rightRow = $this->rightReader->current();

            if($this->rightReader->valid()) {
                $rightId = $this->getRowId($rightRow, $this->rightJoinField);
            }
        }

        return $leftRow;
    }
159504
public function getReadyForBed()
    {
        $busyStatusses = array(ChildProcessContainer::STATUS_SLEEPY,
            ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY
        );
        if (in_array($this->status, $busyStatusses)) {
            //ready for bed
            return;
        }
        if($this->status  == ChildProcessContainer::STATUS_DEAD)
        {
            // do nothing
        }
        else if ($this->status == ChildProcessContainer::STATUS_BUSY) {
            $this->status = ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY;
        } else {
            $this->status = ChildProcessContainer::STATUS_SLEEPY;
        }
        if ($this->process->isRunning()) {
            $this->sendTERMSignal();
        }
    }
1101433
public function readLines()
    {
        if ($this->getFileObject()->isFile()) {
            if ($this->skipEmptyLines) {
                // skip empty lines
                $lines = file($this->getFileObject()->getPathname(), FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
            } else {
                $lines = file($this->getFileObject()->getPathname(), FILE_IGNORE_NEW_LINES);
            }

            if (is_array($lines)) {
                return $lines;
            }
        }
        return array();
    }
126746
public function getReadTemplate()
    {
        if (null === $this->readTemplate) {
            $template = rtrim($this->getTemplatePrefix(), '/') . '/' . $this->getReadSuffix();
            $this->setReadTemplate($template);
        }

        return $this->readTemplate;
    }
817767
protected function next()
    {
        $get = $this->get();
        if ($get === '/') {
            switch ($this->peek()) {
                case '/':
                    $this->consumeSingleLineComment();
                    $get = "\n";
                    break;
                case '*':
                    $this->consumeMultipleLineComment();
                    $get = ' ';
                    break;
            }
        }

        return $get;
    }
920297
protected function _getInput() {
        if (function_exists('readline') && function_exists('readline_add_history')) {
            $line = readline($this->_getPrompt());
            readline_add_history($line);
            return $line;
        }
        echo $this->_getPrompt();
        $line = Garp_Cli::prompt();
        return $line;
    }
1080103
public function prompt()
    {
        if ($this->hasReadline) {
            readline_callback_handler_install($this->getPrompt(), [ $this, 'lineHandler' ]);
        } else {
            if ($this->paused) { $this->resume(); }
            $this->console->log($this->getPrompt());
        }

        return $this;
    }
549018
public function proxyRead()
    {
        $proxyState = $this->proxyState;
        Client::debug('proxy readState: ', $proxyState);
        if ($proxyState === 2) {
            $buf = $this->read(2);
            if ($buf === "\x05\x00") {
                $this->proxyState = 5;
            } elseif ($buf === "\x05\x02") {
                $this->proxyState = 3;
            }
        } elseif ($proxyState === 4) {
            $buf = $this->read(2);
            if ($buf === "\x01\x00") {
                $this->proxyState = 5;
            }
        } elseif ($proxyState === 6) {
            $buf = $this->read(10);
            if (substr($buf, 0, 4) === "\x05\x00\x00\x01") {
                $this->proxyState = 0;
            }
        }
        return $proxyState !== $this->proxyState;
    }
15012
public function getReadHandler()
    {
        if (null === $this->stream) {
            $this->stream = fopen($this->uri, 'r');
        }
        return $this->stream;
    }
696310
public function useReadline()
    {
        return isset($this->useReadline) ? ($this->hasReadline && $this->useReadline) : $this->hasReadline;
    }
109255
public function getLines()
    {
        $lines = explode(PHP_EOL, $this->comment);

        $wrapper = function($line)
        {
            return new Line($line);
        };

        return array_map($wrapper, $lines);
    }
1289711
public function read()
    {
        if ($this->_canReadline) {
            $line = readline('');
            if (strlen($line) > 0) {
                readline_add_history($line);
            }

            return $line;
        }

        return fgets($this->_input);
    }
1102157
public static function package()
    {
        if (self::$package !== null) {
            return self::$package;
        }

        $readCallback = function (\Protobuf\ReadContext $context, $wire) {
            $reader = $context->getReader();
            $length = $context->getLength();
            $stream = $context->getStream();

            \Protobuf\WireFormat::assertWireType($wire, 9);

            $value = $reader->readString($stream);

            return $value;
        };

        $writeCallback = function (\Protobuf\WriteContext $context, $value) {
            $stream      = $context->getStream();
            $writer      = $context->getWriter();
            $sizeContext = $context->getComputeSizeContext();

            $writer->writeVarint($stream, 400018);
            $writer->writeString($stream, $value);
        };

        $sizeCallback = function (\Protobuf\ComputeSizeContext $context, $value) {
            $calculator = $context->getSizeCalculator();
            $size       = 0;

            $size += 3;
            $size += $calculator->computeStringSize($value);

            return $size;
        };

        return self::$package = new \Protobuf\Extension\ExtensionField('\\google\\protobuf\\FileOptions', 'package', 50002, $readCallback, $writeCallback, $sizeCallback, __METHOD__);
    }
727669
protected function readLine()
    {
        if (! $this->valid()) {
            throw new Error('End of stream reached, no data to read');
        }
        $this->currentData = fgetcsv($this->fp, null, $this->delimiter, $this->enclosure);
        // Check if EOF is reached
        if (false === $this->currentData) {
            return false;
        } elseif (array(null) == $this->currentData) {
            /*
             * An empty line in the csv file
             * is returned as an array containing a NULL value.
             */
            if (! $this->ignoreEmptyLines) {
                throw new Error('Empty line found in file');
            }
            return $this->readLine();
        }
        $this->curLine++;

        if ($this->inputEncoding != $this->outputEncoding) {
            $inEnc = $this->inputEncoding;
            $outEnc = $this->outputEncoding;
            array_walk($this->currentData, function (&$str) use ($inEnc, $outEnc) {
                $str = mb_convert_encoding($str, $outEnc, $inEnc);
            });
        }

        return $this->currentData;
    }
116218
public function getIterator()
    {
        if (!file_exists($this->filepath)) {
            //TODO: throw exception instead?
            return null;
        }
        $header = $this->hasheader ? $this->getFirstRow() : null;
        $output = array();

        $config = new LexerConfig();
        $config->setDelimiter($this->delimiter);
        $config->setEnclosure($this->enclosure);
        $config->setIgnoreHeaderLine($this->hasheader);

        $interpreter = new Interpreter();
        // Ignore row column count consistency
        $interpreter->unstrict();
        $interpreter->addObserver(function (array $row) use (&$output, $header) {
            if ($header) {
                //create new row using headings as keys
                $newrow = array();
                foreach ($header as $k => $heading) {
                    if (isset($row[$k])) {
                        $newrow[$heading] = $row[$k];
                    }
                }
                $row = $newrow;
            }
            $output[] = $row;
        });

        $lexer = new Lexer($config);
        $lexer->parse($this->filepath, $interpreter);

        return new ArrayIterator($output);
    }
499549
public function getPeek()
    {
        if (!$this->peeking) {
            $this->peeked = $this->getNext();
            $this->peeking = true;
        }

        return $this->peeked;
    }