Yii2: Suggestion to use int/bool instead of integer/boolean in doc blocks

Created on 30 Jul 2016  路  4Comments  路  Source: yiisoft/yii2

Yii currently uses long type names for int/bool in doc blocks:
https://github.com/yiisoft/yii2/blob/master/docs/internals/core-code-style.md#44-doc-blocks

I adopted this standard, however it always meant a certain discomfort for me since PhpStorm auto-generates PHPDoc stubs using shot type names. It made me submit a feature request to JetBrains to support long type names in auto-generated PHPDoc. Upon this request I was suggested to reconsider the usage of the long form at all as PHP 7 allows only the short form for type hinting.

Thus, I would suggest to consider this change in the Yii Code Style standards as well.

hacktoberfest

Most helpful comment

Yes. That makes perfect sense and I've just included the rule into PSR-12: https://github.com/php-fig/fig-standards/commit/a77993bdf52eb6d5cb9ca37dba3af4df9e3b909c

Could be applied to Yii as well.

All 4 comments

PHP 7 allows only the short form for type hinting.

That's exactly the reason I use short forms in PHPDoc in my own PHP code. And for the same reason I use float instead of double too.

Yes. That makes perfect sense and I've just included the rule into PSR-12: https://github.com/php-fig/fig-standards/commit/a77993bdf52eb6d5cb9ca37dba3af4df9e3b909c

Could be applied to Yii as well.

need to adjust this array to allow correct links in the documentation generator if we change it: https://github.com/yiisoft/yii2-apidoc/blob/474e7b9be71f8627c79ece7605c1ca50957e1189/renderers/BaseRenderer.php#L104-L116

It should be adjusted anyway to include both forms since both are actually allowed by PHP except return types.

Was this page helpful?
0 / 5 - 0 ratings