ThinkPHP/Library/Vendor/Boris/Boris.php
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
/* vim: set shiftwidth=2 expandtab softtabstop=2: */
namespace Boris;
/**
* Boris is a tiny REPL for PHP.
*/
class Boris {
const VERSION = "1.0.8";
private $_prompt;
private $_historyFile;
private $_exports = array();
private $_startHooks = array();
private $_failureHooks = array();
private $_inspector;
/**
* Create a new REPL, which consists of an evaluation worker and a readline client.
*
* @param string $prompt, optional
* @param string $historyFile, optional
*/
public function __construct($prompt = 'boris> ', $historyFile = null) {
$this->setPrompt($prompt);
$this->_historyFile = $historyFile
? $historyFile
: sprintf('%s/.boris_history', getenv('HOME'))
;
$this->_inspector = new ColoredInspector();
}
/**
* Add a new hook to run in the context of the REPL when it starts.
*
* @param mixed $hook
*
* The hook is either a string of PHP code to eval(), or a Closure accepting
* the EvalWorker object as its first argument and the array of defined
* local variables in the second argument.
*
* If the hook is a callback and needs to set any local variables in the
* REPL's scope, it should invoke $worker->setLocal($var_name, $value) to
* do so.
*
* Hooks are guaranteed to run in the order they were added and the state
* set by each hook is available to the next hook (either through global
* resources, such as classes and interfaces, or through the 2nd parameter
* of the callback, if any local variables were set.
*
* @example Contrived example where one hook sets the date and another
* prints it in the REPL.
*
* $boris->onStart(function($worker, $vars){
* $worker->setLocal('date', date('Y-m-d'));
* });
*
* $boris->onStart('echo "The date is $date\n";');
后面还有 114 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
