Skip to content

Commit 93c8ea8

Browse files
committed
Update readme
1 parent 2326d60 commit 93c8ea8

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,80 @@ $dynamicMethodAccessor
223223
echo $result;
224224
```
225225

226+
### Call ambiguous method into Java from PHP
227+
- PHP types are ambiguous than Java.
228+
- You may want to call a methods in PHP that contain long type in Java.
229+
In its case, you can call a method as follows:
230+
231+
- ex. ) Wrap with `\PHPJava\Kernel\Types\_Long`. We recommend this.
232+
#### In Java
233+
```java
234+
class Test
235+
{
236+
public static void includingLongTypeParameter(long n)
237+
{
238+
System.out.println(n);
239+
}
240+
241+
}
242+
```
243+
244+
#### In PHP
245+
```php
246+
<?php
247+
$javaClass->getInvoker()->getStatic()->getMethods()->call(
248+
'includingLongTypeParameter',
249+
new \PHPJava\Kernel\Types\_Long(1234)
250+
);
251+
```
252+
253+
The example will return `1234`.
254+
255+
256+
- ex. ) Set `false` to strict mode within options.
257+
258+
#### In PHP
259+
```php
260+
<?php
261+
use PHPJava\Core\JavaClass;
262+
use PHPJava\Core\JavaClassFileReader;
263+
264+
$javaClass = new JavaClass(
265+
new JavaClassFileReader('Test'),
266+
[
267+
'strict' => false,
268+
]
269+
);
270+
```
271+
272+
### Runtime options
273+
- Available options on `JavaClass` or `JavaArchive` is below:
274+
275+
|Options | Value | Default | Description |Targeted |
276+
|:-------------:|:-------------:|:-------------:|:-------------:|:-------------:|
277+
| max_stack_exceeded | integer | 9999 | Execute more than the specified number of times be stopped the operation. | JavaClass |
278+
| strict | boolean | true | If strict mode is `true` then execute method, variables and so on with strict. But if strict mode is `false` then execute ambiguously method, variable and etc in PHPJava. | Both |
279+
| validation.method.arguments_count_only | boolean | false | If this mode `true` then ClassResolver validate arguments size only. | JavaClass |
280+
281+
- For example:
282+
```php
283+
<?php
284+
use PHPJava\Core\JavaClass;
285+
use PHPJava\Core\JavaClassFileReader;
286+
287+
$javaClass = new JavaClass(
288+
new JavaClassFileReader('Test'),
289+
[
290+
'max_stack_exceeded' => 12345,
291+
'validation' => [
292+
'method' => [
293+
'arguments_count_only' => true,
294+
],
295+
],
296+
]
297+
);
298+
```
299+
226300
### Output PHPJava operations
227301

228302
- Output debug trace as follows if you want to show operation log:

0 commit comments

Comments
 (0)