Cristiano,

I haven't tested the code below.. but I assume you are using php mapscript 5.6 or ealier. You cannot use the php clone keyword with mapscript object since it has no idea how to clone the internal object properly. If you would have used php mapscript from svn (which includes the refactoring) to do this test, you would have gotten an error since the object are not clonable. It's in my enhancement todo list to make some objects clonable. I have no idea when this will be done though.

Alan

Cristiano Sumariva wrote:
I executed this example and object comparison returned true on clone call.
But it returned false when I request another reference from same layer from getLayer.
Should not it return true ?


#/* 09/04/2010 test for mapserver object comparison on PHP.
# If I clone a layer object from a map instance and compare the cloned with ref, do they are the same ?
# Answer: yes.
# PHP state: Two object instances are equal if they have the same attributes and values, and are instances of the same class
#require_once dirname( __FILE__ ).'/class/mapfile/Mapfile.php';
#Mapfile::checkLibrary();

$map = ms_newMapObj( '' );
var_dump( $map->numlayers );
$l = ms_newlayerobj( $map );
var_dump( $map->numlayers );
print( nl2br( "\n" ) );
$l->set( 'type', MS_LAYER_POLYGON );
#var_dump( $l->type );
$lClone = clone $l;
var_dump( __LINE__, ( $l == $lClone ) );
var_dump( __LINE__, ( $l == $map->getLayer( 0 ) ) );
$lRef = $map->getLayer( 0 );
var_dump( __LINE__, ( $l == $lRef ), $l->type, $lRef->type );

#repeated test but now with $l from the reference from getLayer
print( nl2br( "\n" ) );
$l = $map->getLayer( 0 );
$lClone = clone $l;
var_dump( __LINE__, ( $l == $lClone ) );
var_dump( __LINE__, ( $l == $map->getLayer( 0 ) ) );
$lRef = $map->getLayer( 0 );
var_dump( __LINE__, ( $l == $lRef ), $l->type, $lRef->type );

exit;
------------------------------------------------------------------------

_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users


--
Alan Boudreault
Mapgears
http://www.mapgears.com/
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to