{"action":"closed","issue":{"url":"https://api.github.com/repos/wsdl2phpgenerator/wsdl2phpgenerator/issues/202","labels_url":"https://api.github.com/repos/wsdl2phpgenerator/wsdl2phpgenerator/issues/202/labels{/name}","comments_url":"https://api.github.com/repos/wsdl2phpgenerator/wsdl2phpgenerator/issues/202/comments","events_url":"https://api.github.com/repos/wsdl2phpgenerator/wsdl2phpgenerator/issues/202/events","html_url":"https://github.com/wsdl2phpgenerator/wsdl2phpgenerator/issues/202","id":56601799,"number":202,"title":"Infinite recursion if type's base type is itself","user":{"login":"HighOnMikey","id":3639519,"avatar_url":"https://avatars.githubusercontent.com/u/3639519?v=3","gravatar_id":"","url":"https://api.github.com/users/HighOnMikey","html_url":"https://github.com/HighOnMikey","followers_url":"https://api.github.com/users/HighOnMikey/followers","following_url":"https://api.github.com/users/HighOnMikey/following{/other_user}","gists_url":"https://api.github.com/users/HighOnMikey/gists{/gist_id}","starred_url":"https://api.github.com/users/HighOnMikey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HighOnMikey/subscriptions","organizations_url":"https://api.github.com/users/HighOnMikey/orgs","repos_url":"https://api.github.com/users/HighOnMikey/repos","events_url":"https://api.github.com/users/HighOnMikey/events{/privacy}","received_events_url":"https://api.github.com/users/HighOnMikey/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-04T23:05:09Z","updated_at":"2015-04-17T10:06:04Z","closed_at":"2015-04-17T10:06:04Z","body":"I'm working with a web service which imports http://www.w3.org/2005/05/xmlmime. The base type for the types defined in this schema reference themselves. The struct returned from this particular service:\r\n\r\n```\r\nstruct base64Binary {\r\n base64Binary _;\r\n anonymous0 contentType;\r\n}\r\n```\r\n\r\nDue to this self-reference, [`getBaseTypeMembers()`](https://github.com/wsdl2phpgenerator/wsdl2phpgenerator/blob/6cb408acbc6dab52a8bb977d289d941dfba69ab2/src/ComplexType.php#L241) will call itself with infinite recursion.\r\n\r\nAdding some quick checks resolves the issue:\r\n\r\n```php\r\n    protected function getBaseTypeMembers(ComplexType $type)\r\n    {\r\n        if (empty($type->baseType)) {\r\n            return array();\r\n        }\r\n\r\n        if ($type === $type->baseType)\r\n        {\r\n            return array();\r\n        }\r\n\r\n        return array_merge($this->getBaseTypeMembers($type->baseType), $type->baseType->getMembers());\r\n    }\r\n```\r\n\r\nHowever, the generated class for a self-referenced type will be extended by itself in [`generateClass()`](https://github.com/wsdl2phpgenerator/wsdl2phpgenerator/blob/6cb408acbc6dab52a8bb977d289d941dfba69ab2/src/ComplexType.php#L62). So, more checks are needed:\r\n\r\n```php\r\n    protected function generateClass()\r\n    {\r\n\r\n// ...\r\n\r\n        $classBaseType = '';\r\n\r\n        if ($this->baseType !== null && $this->baseType !== $this) {\r\n            $classBaseType = $this->baseType->getPhpIdentifier();\r\n        }\r\n\r\n        $class = new PhpClass(\r\n            $this->phpIdentifier,\r\n            false,\r\n            $classBaseType\r\n        );\r\n\r\n// ...\r\n    }\r\n```"}}