Skip to content

refactor: convert ConsentType to a PHP 8.1 backed enum#1929

Open
kayjoosten wants to merge 1 commit intofeature/stabilize-consent-hashfrom
feature/consent-type-enum
Open

refactor: convert ConsentType to a PHP 8.1 backed enum#1929
kayjoosten wants to merge 1 commit intofeature/stabilize-consent-hashfrom
feature/consent-type-enum

Conversation

@kayjoosten
Copy link
Contributor

Replace the ConsentType value class (with its deprecated public constructor since ~2015) with a proper backed enum.

  • ConsentType is now enum ConsentType: string with cases Explicit = 'explicit' and Implicit = 'implicit'
  • The deprecated public constructor, the explicit()/implicit() named constructors and the equals() method are removed
  • DbalConsentRepository uses ConsentType::from() to hydrate from DB
  • Legacy Consent model methods now accept ConsentType and pass ->value into SQL parameter arrays
  • All call sites updated from TYPE_EXPLICIT/TYPE_IMPLICIT constants and named constructors to enum cases
  • ConsentTypeTest updated: invalid-string rejection tested via from(), equality via assertSame() on enum singletons

@kayjoosten
Copy link
Contributor Author

Note: @johanib ik zag hier een @deprecated van 2015.... dus ik kon het echt niet laten. Ik heb het wel apart getrokken van de ander branch maar als je dit kan reviewen merge ik hem in de andere pr.

@kayjoosten kayjoosten requested a review from johanib March 6, 2026 14:36
@kayjoosten kayjoosten force-pushed the feature/stabilize-consent-hash branch 6 times, most recently from b183015 to c3faaec Compare March 9, 2026 15:01
@kayjoosten kayjoosten force-pushed the feature/stabilize-consent-hash branch 2 times, most recently from ab9366f to 2aeffa0 Compare March 16, 2026 16:32
@baszoetekouw baszoetekouw moved this from New to In Progress in PHP development Mar 17, 2026
@kayjoosten kayjoosten force-pushed the feature/stabilize-consent-hash branch 3 times, most recently from b5009cb to 260c436 Compare March 17, 2026 13:48
@kayjoosten kayjoosten force-pushed the feature/consent-type-enum branch from 2348282 to 5981524 Compare March 17, 2026 14:15
Replace the ConsentType value class (with its deprecated public
constructor since ~2015) with a proper backed enum.

- ConsentType is now `enum ConsentType: string` with cases
  Explicit = 'explicit' and Implicit = 'implicit'
- The deprecated public constructor, the explicit()/implicit() named
  constructors and the equals() method are removed
- DbalConsentRepository uses ConsentType::from() to hydrate from DB
- Legacy Consent model methods now accept ConsentType and pass ->value
  into SQL parameter arrays
- All call sites updated from TYPE_EXPLICIT/TYPE_IMPLICIT constants
  and named constructors to enum cases
- ConsentTypeTest updated: invalid-string rejection tested via from(),
  equality via assertSame() on enum singletons
@kayjoosten kayjoosten force-pushed the feature/consent-type-enum branch from 5981524 to e6ffa0d Compare March 17, 2026 14:45
@johanib
Copy link
Contributor

johanib commented Mar 19, 2026

Looks good, but need to fix test before merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants