-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathLambda.php
More file actions
76 lines (64 loc) Β· 1.56 KB
/
Lambda.php
File metadata and controls
76 lines (64 loc) Β· 1.56 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
declare(strict_types=1);
namespace PHPJava\Kernel\Internal;
use PHPJava\Core\JavaClass;
use PHPJava\Core\JavaClassInterface;
use PHPJava\Kernel\Structures\MethodInfo;
class Lambda implements JavaClassInterface
{
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $descriptor;
/**
* @var string
*/
private $class;
/**
* @var MethodInfo|\ReflectionMethod
*/
private $methodEntity;
/**
* @var JavaClassInterface|string
*/
private $classObject;
public function __construct(JavaClassInterface $javaClass, string $invokedName, string $name, string $descriptor, string $class)
{
$this->name = $name;
$this->descriptor = $descriptor;
$this->class = $class;
$this->methodEntity = [
$name,
$invokedName,
$javaClass,
];
$this->classObject = JavaClass::load(
$class,
$javaClass->getOptions()
);
}
/**
* @param $name
* @param $arguments
*/
public function __call($name, $arguments)
{
return $this->classObject->{$name}(...$arguments);
}
public function __invoke(string $name, ...$arguments)
{
[$actualMethodName, $entityMethodName, $referredClassObject] = $this->methodEntity;
return $referredClassObject
->getInvoker()
->getStatic()
->getMethods()
->call(
$actualMethodName,
...$arguments
);
}
}