Pinq\Parsing\FunctionReflection::fromCallable PHP Method

fromCallable() public static method

Creates a new function reflection instance from the supplied callable.
public static fromCallable ( callable $callable ) : self
$callable callable
return self
    public static function fromCallable(callable $callable)
    {
        $reflection = Reflection::fromCallable($callable);
        return new self($callable, $reflection, FunctionSignature::fromReflection($reflection), FunctionLocation::fromReflection($reflection), FunctionScope::fromReflection($reflection, $callable));
    }

Usage Example

 /**
  * @dataProvider expressions
  */
 public function testExpressionCompilation($phpCallable, $expectedSql)
 {
     // Parse the first statement from callable into an expression tree.
     $expression = FunctionInterpreter::getDefault()->getStructure(FunctionReflection::fromCallable($phpCallable))->getBodyExpressions()[0];
     $compiler = new ExpressionCompiler(new Select($this->pdo, new TableSourceInfo('table'), new ParameterCollection()));
     $this->assertSame($expectedSql, $compiler->compile($expression), 'PHP Code: ' . $expression->compile());
 }