StateMachineBundle icon indicating copy to clipboard operation
StateMachineBundle copied to clipboard

Add php8.1 enum support

Open tdumalin opened this issue 3 years ago • 0 comments

Hi there,

It would be nice if the bundle could be compatible with the new php enum:

https://www.php.net/manual/fr/language.enumerations.basics.php

Here's some sample with the current doc:

<?php

namespace App\Enum;

enum ArticleStates: string
{
      case NewArticle = 'new';
      case PendingReview = 'pending_review';
      //...
}

<?php

namespace App\Entity;

use  App\Enum\ArticleStates;

class Article
{
     /** @var ArticleStates */
     private $state;
     //...

   public function getState() : ArticleStates
   {
         return $this->state;
   }

  public function setState(ArticleStates $state) : self
  {
     $this->state = $state;
      return $this;
  } 
  //...
}

tdumalin avatar Mar 08 '22 16:03 tdumalin