NotionCommotion Posted May 19, 2021 Share Posted May 19, 2021 I always struggle with keeping my annotations pretty. Just about ever IDE beautifies PHP, there are many online PHP beautifiers, and notepad++ and other apps are available. None of them seem to work with annotations. Also, would like to validate them at the same time. Anyone know of any plugins or websites which do this? I would be fine with just cutting and pasting just the comment block and it need not format the entire PHP script (I probably wouldn't even use the PHP portions as git would probably see changes). If nothing is available, suppose I could create one myself. Before doing so, however, would like to better understand best practices. For instance, how many spaces for indentations, what is acceptable to put inline (i.e. the @ORM\Table item should definitely not be on a single line), etc. Thank! /** * @ORM\Entity() * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_position_serie", columns={"test_chart_id", "position"}), @ORM\UniqueConstraint(name="unique_name_serie", columns={"test_chart_id", "name"})}) * @ApiResource( * collectionOperations={ * "get" = { * "method"="GET", * }, * "post" = { * } * }, * itemOperations={ * "get" = { * "openapi_context" = { * "parameters" = { * { * "name" = "nameOfQueryParameter", * "in" = "query", * "description" = "Description goes here", * "schema" = { * "type" = "string" * } * } * } * } * }, * "put" = { * }, * "patch" = { * }, * "delete" = { * } * } * ) */ Quote Link to comment https://forums.phpfreaks.com/topic/312741-formatting-annotations/ Share on other sites More sharing options...
NotionCommotion Posted May 23, 2021 Author Share Posted May 23, 2021 Bad question or no answers? Does difficulty of formatting annotations annoy anyone other than me? Quote Link to comment https://forums.phpfreaks.com/topic/312741-formatting-annotations/#findComment-1586751 Share on other sites More sharing options...
kicken Posted May 24, 2021 Share Posted May 24, 2021 I don't use annotations, so N/A. PHPStorm will apply some basic formatting to doc blocks, but trying your sample annotation it doesn't seem to do anything with it outside of wrapping long lines. As far as style, do whatever you like, just be consistent. Quote Link to comment https://forums.phpfreaks.com/topic/312741-formatting-annotations/#findComment-1586757 Share on other sites More sharing options...
NotionCommotion Posted May 27, 2021 Author Share Posted May 27, 2021 On 5/23/2021 at 11:30 PM, kicken said: I don't use annotations, so N/A. Neither did I for quite a while based on your advice. My main reason for starting to use them was being able to see all relevant information in one place (i.e. database and serialization). That being said, have special comments in code still kind of annoys me, and I like having this content divorced from the code. Still find it kind of odd that someone hasn't come up with a annotation formatter/validator. Guess much is based on what is using them, but still... Quote Link to comment https://forums.phpfreaks.com/topic/312741-formatting-annotations/#findComment-1586831 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.