munus icon indicating copy to clipboard operation
munus copied to clipboard

Add tuple generator

Open mtk3d opened this issue 2 years ago • 6 comments

Hello 😄 I prepared my proposal of Tuples with generics, as discussed in here https://github.com/munusphp/munus/issues/38 It's just proposal, still in progress, there is no tests yet.

I started by just coding this classes manually, but making them manually without mistakes is hard, and laborious. So following vavr's approach, I built a template with command that generates the code of the Tuples. I'm not 100% contented by this solution, but that's the fastest and lightest solution that came to my mind.

I'm also wondering about using library like https://github.com/nette/php-generator. I could install it as a dev dependency and use it to generating the code in object oriented way, and it could be more readable maybe 🤔

@akondas What do you think about that?

mtk3d avatar Feb 19 '23 21:02 mtk3d

I've replaced it with better implementation using nette/php-generator. It works ways better in my opinion. There is a test that is testing first 3 classes of Tuples by comparing strings, but I wrote them only in development purpose. In final implementation that doesn't make sense to keep them. Better will be to test only their behaviors and php-cs-fixer will check the code style. It's still in progress and require a lot of refactoring.

mtk3d avatar Feb 21 '23 18:02 mtk3d

Todo:

  • [x] Make some maintenance on master branch, do decrease size of PR https://github.com/munusphp/munus/pull/77
  • [x] More test coverage for TupleN classes
  • [x] Generator command CI checker, to avoid manual changes in generated classes

mtk3d avatar Feb 22 '23 18:02 mtk3d

Zrzut ekranu 2023-02-23 o 00 36 37 Ok, I belive I'm done. ~1300 lines of the PR is generated automatically, but it's still quite big, sorry for that 😄

I've added validation command to composer tests which is validating if existing Tuples has been generated by latest version of generator. I covered Tuples in 100% in tests what I believe is quite important for generated classes.

mtk3d avatar Feb 22 '23 23:02 mtk3d

looks cool, are you happy to rebase and wait for php 8.2 upgarde?

akondas avatar Sep 19 '23 17:09 akondas

looks cool, are you happy to rebase and wait for php 8.2 upgarde?

Yes, thank you! 😄 I've refactored generate command a little bit. Right now it's a single command to validate and generate and it shows diff if validation fails: Zrzut ekranu 2023-09-24 o 15 48 06

mtk3d avatar Sep 24 '23 13:09 mtk3d

Hey @mtk3d, Is there anything left to do here, because I would like to give it a chance, it's a big PR and I think it would be a pity to leave it open :)

akondas avatar Jan 08 '24 09:01 akondas

Hi @mtk3d, ping again, If you don't have time right now, I can fix the changes after rebase and do a merge.

akondas avatar May 26 '24 17:05 akondas

Closes #38

akondas avatar May 28 '24 06:05 akondas

Thanks @mtk3d :beers:

akondas avatar May 28 '24 06:05 akondas

Hey @akondas sorry for not responding I had an apartment renovation and it totally consumed all my free time and energy Thanks for merge 🍻

mtk3d avatar Jun 19 '24 18:06 mtk3d