Mantis - Quercus
Viewing Issue Advanced Details
1109 feature always 05-13-06 18:27 07-18-06 11:23
koreth  
ferg  
normal  
closed 3.0.19  
fixed  
none    
none 3.0.20  
0001109: PHP-Java communication: access to complex structures.
I've been playing around with talking to a Java class from PHP code, and one thing I noticed immediately is that the Java-PHP interface doesn't deal with complex PHP types. It would be great if, for example, a Map returned by a Java method looked like an associative array to the PHP code. Likewise, a Collection should act like an array. That would allow much more idiomatic PHP code. The way JSTL EL handles collections and maps is kind of what I'm thinking.

More important, though, is the reverse. Right now, as far as I can tell, if the PHP code wants to pass a complex structure to the Java side, the Java code has to provide an interface to construct the structure piece by piece, because arguments other than primitives (and references to Java objects) can't be passed to Java code.

<?php
$x['y'] = 'z';
$javaObject->doSomething($x);
?>

results in a null argument to the doSomething() method in interpreted mode, and a NullPointerException inside Quercus once the PHP class is compiled.

It would be okay to just pass in a Quercus Value object, which the Java code could then navigate as needed. Better would be to auto-convert to an untyped Map or Collection (recursively, of course, to handle multidimensional arrays). Best of all would be auto-conversion that pays attention to the argument types in the target method, e.g.

public void doSomething(Map<String,Map<Integer,String>> arg, double[] list)

for a two-dimensional array of strings with an integer second dimension and a list of doubles.

Notes
(0001412)
ferg   
07-18-06 11:23   
php/3cc-