Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Oct 24, 2014
2 parents 6672a73 + 7d98215 commit 6be7c75
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"require": {
"php": ">=5.3.0",
"symfony/console": ">=2.3.10, <2.6.0",
"nikic/php-parser": "~1.0@dev",
"dnoegel/php-xdg-base-dir": "dev-master@dev"
"nikic/php-parser": "~1.0",
"dnoegel/php-xdg-base-dir": "0.1"
},
"require-dev": {
"phpunit/phpunit": ">=3.7, <4.3",
Expand All @@ -35,7 +35,7 @@
"bin": ["bin/psysh"],
"extra": {
"branch-alias": {
"dev-master": "0.2.0-dev"
"dev-develop": "0.2.x-dev"
}
}
}
6 changes: 3 additions & 3 deletions src/Psy/CodeCleaner/ValidFunctionNamePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Function_ as FunctionStmt;
use Psy\Exception\FatalErrorException;

Expand Down Expand Up @@ -43,12 +44,11 @@ public function leaveNode(Node $node)

$this->currentScope[strtolower($name)] = true;
} elseif ($node instanceof FuncCall) {
// if function name is an expression, give it a pass for now.
// if function name is an expression or a variable, give it a pass for now.
$name = $node->name;
if (!$name instanceof Expression) {
if (!$name instanceof Expression && !$name instanceof Variable) {
$shortName = implode('\\', $name->parts);
$fullName = $this->getFullyQualifiedName($name);

if (
!isset($this->currentScope[strtolower($fullName)]) &&
!function_exists($shortName) &&
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
class Shell extends Application
{
const VERSION = 'v0.2.0';
const VERSION = 'v0.2.1';

const PROMPT = '>>> ';
const BUFF_PROMPT = '... ';
Expand Down
2 changes: 2 additions & 0 deletions test/Psy/Test/CodeCleaner/ValidFunctionNamePassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ function theta() {}
theta();
}
"),
// closures
array('$test = function(){};$test()'),
array("
namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
function theta() {}
Expand Down
11 changes: 11 additions & 0 deletions test/Psy/Test/ShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ public function testCodeBufferThrowsParseExceptions()
$shell->flushCode();
}

public function testClosuresSupport()
{
$shell = new Shell($this->getConfig());
$code = '$test = function () {}';
$shell->addCode($code);
$shell->flushCode();
$code = '$test()';
$shell->addCode($code);
$shell->flushCode();
}

public function testWriteStdout()
{
$output = $this->getOutput();
Expand Down

0 comments on commit 6be7c75

Please sign in to comment.