-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AbstractModel::uniqueName returns int when $name and $context already in lower case #254
Labels
Comments
I'll look to it as soon as possible, thx |
No need to hurry because of me. I fixed it in my local copy and completed my project. My fix was rather simple, I just created another array. protected static array $uniqueNames = [];
protected static array $uniqueNamesCounter = [];
protected static function uniqueName(string $name, string $context): string
{
$insensitiveKey = mb_strtolower($name.'_'.$context);
$sensitiveKey = $name.'_'.$context;
if (array_key_exists($sensitiveKey, self::$uniqueNames)) {
return self::$uniqueNames[$sensitiveKey];
}
if (!array_key_exists($insensitiveKey, self::$uniqueNames)) {
self::$uniqueNamesCounter[$insensitiveKey] = 0;
} else {
++self::$uniqueNamesCounter[$insensitiveKey];
}
$uniqueName = $name.(self::$uniqueNamesCounter[$insensitiveKey] ? '_'.self::$uniqueNamesCounter[$insensitiveKey] : '');
self::$uniqueNames[$sensitiveKey] = $uniqueName;
return $uniqueName;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generating from https://www.imonitor.cz/imonws/BaseWS.asmx?WSDL
with default settings taken from your README.MD example.
Parameters of this specific case are:
$name = 'spz'
$context = '000000005edf52d6000000003b6aed65rowmethod'
self::$uniqueNames[$sensitiveKey] === 0
so int 0 is returned
It seems you assumed that $sensitiveKey and $insensitiveKey will always be different so you used the same array for both the counter and resolved unique names.
Fatal error: Uncaught TypeError: Return value of WsdlToPhp\PackageGenerator\Model\AbstractModel::uniqueName() must be of the type string, int returned in /var/www/app/wsdltophp-src/vendor/wsdltophp/packagegenerator/src/Model/AbstractModel.php:439
setOrigin('https://www.imonitor.cz/imonws/BaseWS.asmx?WSDL') ->setDestination('./imonitor-soap') ->setComposerName('xxx/imonitor-soap'); // Generator instantiation $generator = new Generator($options); // Package generation $generator->generatePackage();Stack trace:
#0 /var/www/app/wsdltophp-src/vendor/wsdltophp/packagegenerator/src/Model/StructAttribute.php(43): WsdlToPhp\PackageGenerator\Model\AbstractModel::uniqueName('spz', '0000000001bcc60...')
#1 /var/www/app/wsdltophp-src/vendor/wsdltophp/packagegenerator/src/File/Struct.php(165): WsdlToPhp\PackageGenerator\Model\StructAttribute->getUniqueString('spz', 'method')
#2 /var/www/app/wsdltophp-src/vendor/wsdltophp/packagegenerator/src/File/Struct.php(142): WsdlToPhp\PackageGenerator\File\Struct->getStructMethodParameter(Object(WsdlToPhp\PackageGenerator\Model\StructAttribute))
#3 /var/www/app/wsdltophp-src/vendor/wsdltophp/packagegenerator/src/File/Struct.php(108): WsdlToPhp\PackageGenerator\File\Struct->getStructMethodParametersValues()
#4 /var/www/app/wsdltophp-src/vendor/wsd in /var/www/app/wsdltophp-src/vendor/wsdltophp/packagegenerator/src/Model/AbstractModel.php on line 439
The text was updated successfully, but these errors were encountered: