You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
<?php
|
|
/* ===========================================================================
|
|
* Copyright (c) 2018-2019 Zindex Software
|
|
*
|
|
* Licensed under the MIT License
|
|
* =========================================================================== */
|
|
|
|
namespace Opis\Closure;
|
|
|
|
use Closure;
|
|
use SuperClosure\Analyzer\ClosureAnalyzer;
|
|
|
|
class Analyzer extends ClosureAnalyzer
|
|
{
|
|
/**
|
|
* Analyzer a given closure.
|
|
*
|
|
* @param Closure $closure
|
|
*
|
|
* @return array
|
|
*/
|
|
public function analyze(Closure $closure)
|
|
{
|
|
$reflection = new ReflectionClosure($closure);
|
|
$scope = $reflection->getClosureScopeClass();
|
|
|
|
$data = [
|
|
'reflection' => $reflection,
|
|
'code' => $reflection->getCode(),
|
|
'hasThis' => $reflection->isBindingRequired(),
|
|
'context' => $reflection->getUseVariables(),
|
|
'hasRefs' => false,
|
|
'binding' => $reflection->getClosureThis(),
|
|
'scope' => $scope ? $scope->getName() : null,
|
|
'isStatic' => $reflection->isStatic(),
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* @param array $data
|
|
* @return mixed
|
|
*/
|
|
protected function determineCode(array &$data)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @param array $data
|
|
* @return mixed
|
|
*/
|
|
protected function determineContext(array &$data)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|