Instructions for Type Declaration Exercise, City Office, could be clearer

I wasn’t clear on whether the instructions were asking me to declare the param/return types so that they are enforced, or document them in comments.

The instructions pre-amble says:

You decide to write some documentation so that it’s easier for your new colleague to hop right in and start using your tools.

Each of the steps, also start with the word “Document.” However, the test seems to test for declaration of types for the purpose of enforcement and none of the community solutions that I glanced at seem to have any phpdoc comments.

For one question in particular, where it says the return type should be “an array of letters”, it made me consider phpdoc because I checked the php.net documentation and couldn’t see a way to declare the array of letters as a return type since I can’t declare typed arrays.

I don’t know if this is something other people also encounter, but if they do, it might be worth considering changing the wording of the exercise. I looked at the “Edit on Github” link and it gives me an option to “Edit in place” but I don’t want to mess anything up since I’m pretty new to all of this, so thought I would post here.

Thanks for pointing that out. As you also found out, PHP does not have all the possibilities to express types in code. And the possibilities it has are not that old and still changing.

That being said, I will clarify the instructions as soon as I have time to do so. The exercise does not require phpdoc comments for complex array contents, just the basic PHP type hints in code.

1 Like
1 Like

Thank you!