Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to get array properly with get, toString shortcuts


I am trying to fetch some array contents in php from Zephir by creating a getter with the shortcut but it always returns NULL.

private static locales = [
  ] {get, toString};
echo "getSupported_locales : " . print_r($f->getSupported_locales()->values) ."\n" ;


getSupported_locales : 1


Problem seems to be due to the property being static. Compiler probably doesn't have the level of sophistication yet to handle this case. If you are deviating from the plain vanilla use case and the shortcuts don't work, it is best to just implement getter/setter/toString yourself and move on for now.

If it is possible for you to leave out the static keyword, then the auto-generated getter will work.

Btw, there are some issues with your "echo" statement - The getter function name should be just getLocales() based on the name of your property. Also, not sure what the ->values is for.