chill-bundles/MIGRATION.md
Julien Fastré 5be85a4fc6
Refactored code to use PHP8 attributes instead of annotations
In this change, Doctrine and validation annotations have been replaced with PHP8 Attributes. The Rector tool has been configured with a list of annotations to convert to attributes. As a consequence, the PHPStan's rules have been updated to reflect these changes. The PHP8's nullable operator (?) has been added where required, and comments in field declaration have been replaced with #[Attribute] syntax.
2024-04-08 12:11:29 +02:00

3.7 KiB

Switch to symfony 5.0

  • the tag chill.role is now renamed to chill_main.provide_role.

    Note: It is not necessary to apply this tag on service definition: the tag is automatically applyied if the service implements \Chill\MainBundle\Security\ProvideRoleInterface.

  • those annotation can be converted to attribute:

    • Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\AccompanyingPeriodValidity
    • Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential
    • Chill\PersonBundle\Validator\Constraints\Household\MaxHolder
    • Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ConfidentialCourseMustHaveReferrer
    • Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\LocationValidity
    • Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap
    • Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck
    • Chill\PersonBundle\Validator\Constraints\Person\Birthdate
    • Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter
    • Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate
    • Chill\ActivityBundle\Validator\Constraints\ActivityValidity
    • Chill\DocStoreBundle\Validator\Constraints\AsyncFileExists
    • Chill\MainBundle\Validation\Constraint\PhonenumberConstraint
    • Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency
    • Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation

    Here is the rector rule that can be used to switch attributes to annotations:

      $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\AccompanyingPeriodValidity'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Household\MaxHolder'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ConfidentialCourseMustHaveReferrer'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\LocationValidity'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Person\Birthdate'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\ActivityBundle\Validator\Constraints\ActivityValidity'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\DocStoreBundle\Validator\Constraints\AsyncFileExists'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Validation\Constraint\PhonenumberConstraint'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency'),
          new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation'),
      ]);