Menu

#11 Duplicate type classes

open
nobody
None
5
2009-07-22
2009-07-22
lxg
No

In certain cases, duplicate class declarations are created, which result in PHP errors (something as "Fatal error: Cannot redeclare class foo in foobarService.php on line 74"). This can for example happen if a standardized object (e.g. for messages or errors) is used multiple times across parent elements.

This may or may not be a problem with the WSDL file or the providing service, however, in order to avoid generating duplicate declarations, you can simply check if a class already exists, and if so, not declarate it again. I know that this may become a problem when you have differing objects by the same name, but as a quick workaround, I recommend a simple check:

---- SNIP ----

$have_type_classes = array();

foreach($service['types'] as $type) {

if (in_array($type['class'], $have_type_classes)) continue;
$have_type_classes[] = $type['class'];

---- SNIP ----

Discussion


Log in to post a comment.