nyamsprod,
@nyamsprod@phpc.social avatar

@Crell I have a question ? https://github.com/thephpleague/csv/blob/master/src/Operator/Comparison.php I use an Enum in the case because to me the number of Comparison operator is finit BUT there is a case for using a class instead for better type hinting ? What do you think from a DX perspective ?

Crell,
@Crell@phpc.social avatar

@nyamsprod Are there cases you'd want to type against just one case, or subset of cases? For that you'd need a class. Otherwise, I think the enum is fine.

Remember that Enums can also implement interfaces. I used that here:

https://github.com/Crell/Serde/tree/master/src/Renaming

nyamsprod,
@nyamsprod@phpc.social avatar

@Crell indeed did not think about interfaces on enum will see if that resolve my issue

Crell,
@Crell@phpc.social avatar

@nyamsprod What is the issue you're running into?

nyamsprod,
@nyamsprod@phpc.social avatar

@Crell trying to avoid/improve this signature

nyamsprod,
@nyamsprod@phpc.social avatar

@Crell currently the best I could do is this

Crell,
@Crell@phpc.social avatar

@nyamsprod You want to replace Closure with the signature of a callable? Interface is the least bad way to do that right now. Possibly using __invoke in the interface.

Combine with Enums that implement that interface for "common implementations".

nyamsprod,
@nyamsprod@phpc.social avatar

@Crell I already avoid callable as this type is a new addition in my list of thing not to type with ... the current signature is fine by me but might not be for end users unless they know what they are doing which is not guarantee but it is the least evil. I'm not sure if adding an interface will do TBH. I may settle with the current signature. Good sleep and being away of the code for a while might convince that this is the best solution at the moment in PHP land

nyamsprod,
@nyamsprod@phpc.social avatar

@Crell opt to remove any method on the enum and used good old classes. The implementation feels a bit more natural IMHO and is usable outside League\CSV enum are still present but the usage is a bit "hidden"
Everything is defined under League\Csv\Constraint

Crell,
@Crell@phpc.social avatar

@nyamsprod The constraints feel like an unbounded set from the looks of them, so I agree, classes are the better solution than enums in this case.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines