1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* Jasper report integration for PHP |
7
|
|
|
* |
8
|
|
|
* @link https://github.com/belgattitude/soluble-jasper |
9
|
|
|
* @author Vanvelthem Sébastien |
10
|
|
|
* @copyright Copyright (c) 2017 Vanvelthem Sébastien |
11
|
|
|
* @license MIT |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Soluble\Jasper\Proxy\Engine\Util; |
15
|
|
|
|
16
|
|
|
use Soluble\Japha\Bridge\Adapter as BridgeAdapter; |
17
|
|
|
use Soluble\Japha\Interfaces\JavaObject; |
18
|
|
|
use Soluble\Jasper\Proxy\Engine\DefaultJasperReportsContext; |
19
|
|
|
use Soluble\Jasper\Proxy\RemoteJavaObjectProxyInterface; |
20
|
|
|
|
21
|
|
|
class LocalJasperReportsContext implements RemoteJavaObjectProxyInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var BridgeAdapter |
25
|
|
|
*/ |
26
|
|
|
private $ba; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var JavaObject Java('net.sf.jasperreports.engine.util.LocalJasperReportsContext') |
30
|
|
|
*/ |
31
|
|
|
private $localContext; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var JavaObject|null Java('net.sf.jasperreports.engine.JasperReportsContext') |
35
|
|
|
*/ |
36
|
|
|
private $parentContext; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Create a local context, if no parentContext is given, assume the DefaultJasperReportsContext. |
40
|
|
|
* |
41
|
|
|
* @param BridgeAdapter $bridgeAdapter |
42
|
|
|
* @param JavaObject $parentContext Java('net.sf.jasperreports.engine.JasperReportsContext') |
43
|
|
|
*/ |
44
|
5 |
|
public function __construct(BridgeAdapter $bridgeAdapter, ?JavaObject $parentContext = null) |
45
|
|
|
{ |
46
|
5 |
|
$this->ba = $bridgeAdapter; |
|
|
|
|
47
|
5 |
|
$this->parentContext = $parentContext; |
48
|
5 |
|
} |
49
|
|
|
|
50
|
1 |
|
public function setFileResolver(JavaObject $fileResolver): void |
51
|
|
|
{ |
52
|
1 |
|
$this->getJavaProxiedObject()->setFileResolver($fileResolver); |
53
|
1 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param JavaObject $classLoader Java('java.lang.ClassLoader') |
57
|
|
|
*/ |
58
|
1 |
|
public function setClassLoader(JavaObject $classLoader): void |
59
|
|
|
{ |
60
|
1 |
|
$this->getJavaProxiedObject()->setClassLoader($classLoader); |
61
|
1 |
|
} |
62
|
|
|
|
63
|
1 |
|
public function removeProperty(string $name): void |
64
|
|
|
{ |
65
|
1 |
|
$this->getJavaProxiedObject()->removeProperty($name); |
66
|
1 |
|
} |
67
|
|
|
|
68
|
1 |
|
public function setPropertiesMap(iterable $properties): void |
69
|
|
|
{ |
70
|
1 |
|
$this->getJavaProxiedObject()->setPropertiesMap($properties); |
71
|
1 |
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param mixed $value |
75
|
|
|
*/ |
76
|
1 |
|
public function setProperty(string $name, $value): void |
77
|
|
|
{ |
78
|
1 |
|
$this->getJavaProxiedObject()->setProperty($name, $value); |
79
|
1 |
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return mixed|null |
83
|
|
|
*/ |
84
|
1 |
|
public function getProperty(string $name) |
85
|
|
|
{ |
86
|
1 |
|
return $this->getJavaProxiedObject()->getProperty($name); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return JavaObject Java('net.sf.jasperreports.engine.util.JasperReportsContext') |
91
|
|
|
*/ |
92
|
5 |
|
public function getJavaProxiedObject(): JavaObject |
93
|
|
|
{ |
94
|
5 |
|
if ($this->localContext === null) { |
95
|
5 |
|
$this->localContext = $this->ba->java( |
96
|
5 |
|
'net.sf.jasperreports.engine.util.LocalJasperReportsContext', |
97
|
5 |
|
$this->parentContext ?? (new DefaultJasperReportsContext($this->ba))->getJavaProxiedObject() |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
5 |
|
return $this->localContext; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.