From 55e35f56255fc07a15ecaf17ab4b59017ffb57bd Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 5 Feb 2015 16:50:13 +0100 Subject: [PATCH] Fix #50 on Github. --- Context.php | 8 ++++- Test/Unit/Bug/Github50.php | 70 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 Test/Unit/Bug/Github50.php diff --git a/Context.php b/Context.php index 39cf348..934cf11 100644 --- a/Context.php +++ b/Context.php @@ -113,8 +113,14 @@ public function offsetGet ( $id ) { if($value instanceof DynamicCallable) return $value($this); - if(true === is_callable($value)) + if(true === is_callable($value)) { + + if( true === is_string($value) + && false === in_array(strtolower($value), get_defined_functions()['user'])) + return $value; + $value = $this->_data[$id] = $value($this); + } return $value; } diff --git a/Test/Unit/Bug/Github50.php b/Test/Unit/Bug/Github50.php new file mode 100644 index 0000000..906f1fc --- /dev/null +++ b/Test/Unit/Bug/Github50.php @@ -0,0 +1,70 @@ + + * @copyright Copyright © 2007-2015 Ivan Enderlin. + * @license New BSD License + */ + +class Github50 extends Test\Unit\Suite { + + public function case_bug ( ) { + + $this + ->given( + $ruler = new LUT(), + $rule = 'variable', + $context = new LUT\Context(), + $context['variable'] = 'file' + ) + ->when(function ( ) use ( $ruler, $rule, $context ) { + + $ruler->assert($rule, $context); + }) + ->error() + ->notExists(); + } +}