Skip to content

Order constructor array by asc #7916

@Lenny4

Description

@Lenny4

When using Symfony we often have entities like this:

<?php

namespace App\Entity\Site;

use App\Traits\TimestampableTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

#[ORM\Entity()]
class SomenEntity
{
    use TimestampableTrait;

    #[ORM\Column(type: Types::INTEGER)]
    #[ORM\GeneratedValue]
    #[ORM\Id]
    #[Groups(['group1', 'group2', 'group3'])]
    private ?int $id = null;

    #[ORM\Column(type: Types::STRING)]
    #[Groups(['group3', 'group1', 'group2'])]
    private ?string $name = null;

    #[ORM\Column(type: Types::BOOLEAN)]
    #[Groups(['group3', 'group2', 'group1'])]
    private ?bool $show = null;
    
    // getter and setters ...
}

Notice that the array of group in Groups are not always written in the same order.
Would you be interested with a rule like this ? A rule which order these groups by ASC or DESC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions