0

Is there a way with php-cs-fixer to define an order for Symfony annotations/PHPDoc ?

Here is two examples of a controller method and an entity property :

 /**
     * @Security()
     *
     * @ParamConverter()
     *
     * @Rest\Post()
     * @Rest\View()
     *
     * @param Request      $request
     * @param xxxInterface $item
     *
     * @return \FOS\RestBundle\View\View
     */
public function myAction(Request $request, xxxInterface $item)

and

/**
 * @var itemInterface
 * @ORM\ManyToOne()
 * @ORM\JoinColumn()
 * @JMS\Groups()
 * @JMS\AccessType()
 * @MyCustomAssert\Assert1
 */
protected $item;

For methods, I want to set the order to @Security, @ParamConverter, @Rest then PHPDoc and for properties, I always want @MyCustomAssert at the end.

Is this something possible with php-cs-fixer ?

Tib
  • 2,553
  • 1
  • 27
  • 46

1 Answers1

0

I think it isn't possible with php-cs-fixer (https://mlocati.github.io/php-cs-fixer-configurator/?version=2.9#version:2.15 might help searching)

However the slevomat coding standard for php code sniffer includes a sniff "SlevomatCodingStandard.Commenting.DocCommentSpacing" which allows you to configure annotationsGroups

The phpcbf script can reorder your annotations using this snif.

Allartk
  • 129
  • 3