Analyzer.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/* ===========================================================================
* Copyright (c) 2018-2021 Zindex Software
*
* Licensed under the MIT License
* =========================================================================== */
namespace Opis\Closure;
use Closure;
use SuperClosure\Analyzer\ClosureAnalyzer;
/**
* @deprecated We'll remove this class
*/
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;
}
}