本文整理汇总了PHP中Psy\Shell::hasCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Shell::hasCode方法的具体用法?PHP Shell::hasCode怎么用?PHP Shell::hasCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psy\Shell
的用法示例。
在下文中一共展示了Shell::hasCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testKeepCodeBufferOpen
public function testKeepCodeBufferOpen()
{
$shell = new Shell($this->getConfig());
$shell->addCode('1 \\');
$this->assertNull($shell->flushCode());
$this->assertTrue($shell->hasCode());
$shell->addCode('+ 1 \\');
$this->assertNull($shell->flushCode());
$this->assertTrue($shell->hasCode());
$shell->addCode('+ 1');
$code = $shell->flushCode();
$this->assertFalse($shell->hasCode());
$code = preg_replace('/\\s+/', ' ', $code);
$this->assertNotNull($code);
$this->assertEquals('return 1 + 1 + 1;', $code);
}
示例2: testCodeBuffer
public function testCodeBuffer()
{
$shell = new Shell();
$shell->addCode('class');
$this->assertNull($shell->flushCode());
$this->assertTrue($shell->hasCode());
$shell->addCode('a');
$this->assertNull($shell->flushCode());
$this->assertTrue($shell->hasCode());
$shell->addCode('{}');
$code = $shell->flushCode();
$this->assertFalse($shell->hasCode());
$code = preg_replace('/\\s+/', ' ', $code);
$this->assertNotNull($code);
$this->assertEquals('class a { }', $code);
}