genericImage on entity model is typecast as an array but returns a string
Describe the bug
The genericImage property on the entity model is declared to return an array but returns a string, dumping the contents of this command, returns a string for me.
Seomatic::$plugin->metaBundles->getGlobalMetaBundle(1)->metaSiteVars->identity->genericImage
This is for Craft CMS 3, although it is the same on Craft CMS 4.
To reproduce
Steps to reproduce the behaviour:
- Output the genericImage property from the meta site vars
- Observe the output is a string not an array as declared on the model
I think it might be mis-typed, and should indeed be a string. Are you having an issue related to it?
I'm having issues if I try and write my docblocks for example if I was to do:
private function _genericSeoImage(): string
{
return Seomatic::$plugin->metaBundles->getGlobalMetaBundle(1)->metaSiteVars->identity->genericImage;
}
I can't declare return as string, because it would conflict and mismatch. Technically not an issue for Craft 3 as it's less strict and can avoid doing it entirely, it would be an issue with Craft CMS 4. Equally declaring as array, will then break other things as it will be a string not an array.
Thanks, will have a look
Yeah that's the resolved image, it should be a string. Addressed in: https://github.com/nystudio107/craft-seomatic/commit/c1fe6e55f75a57339d8eedaab2f83ea44ae6a63e & https://github.com/nystudio107/craft-seomatic/commit/566aa6709d889ba3ec6e97270dc4acd9cc03ef77
Craft CMS 3:
You can try it now by setting your semver in your composer.json to look like this:
"nystudio107/craft-seomatic": "dev-develop as 3.4.38”,
Then do a composer clear-cache && composer update
Craft CMS 4:
…..
You can try it now by setting your semver in your composer.json to look like this:
"nystudio107/craft-seomatic": "dev-develop-v4 as 4.0.8”,
Then do a composer clear-cache && composer update
Thanks for updating the typecast in the plugin! This should fix the issue!