@nyamsprod@phpc.social
@nyamsprod@phpc.social avatar

nyamsprod

@nyamsprod@phpc.social

Software developer. Creator of PHP centric package like league/csv and league/uri. Sponsor me at github.com/sponsors/nyamsprod

This profile is from a federated server and may be incomplete. Browse more on the original instance.

nyamsprod, to random
@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 ?

nyamsprod,
@nyamsprod@phpc.social avatar

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

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

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

nyamsprod, to php
@nyamsprod@phpc.social avatar

Coming soon in the next minor release of League\Csv 😍
still ironing the feature that you can already test on the master branch. give it a try
https://csv.thephpleague.com/9.0/reader/statement/#where-clauses

nyamsprod,
@nyamsprod@phpc.social avatar

@kaystrobach it was already present now just making it a bit more obvious and easy to use I hope.
It feels like SQL but it's 100% PHP at its core

nyamsprod,
@nyamsprod@phpc.social avatar

@thomas_shone should be andWhere will fix the document thanks for the quick look👍

nyamsprod,
@nyamsprod@phpc.social avatar

@derflocki there are a couple reasons why I do not use SQLite. First the package needs no dependencies, two, the feature was already present in the package like 7 years ago I only updated the UX around it and last but not least I seldom encounter CSV that adheres fully to the draft/informal RDC. Hence using the SQLite extension would not solve CSV parsing in real world IMHO.

nyamsprod, to random French
@nyamsprod@phpc.social avatar

@derickr @Girgias I have updated my Draft RFC for base32_encode/base32_decode. Let me know what you think about the new proposal.
https://gist.github.com/nyamsprod/8a5cf21c136952a46ec8836f29738c82

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias what's easier to start with the code or the RFC process ? I presume both can be made in parallel. That's brand new territories from me so any advice is welcomed. Also since I do not know C I can create a branch and already add tests if that can help

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias OK when I have time will fork and create a branch with the expected tests to start wiith

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias I will create a branch and add the tests files for the implementation I think that all I can do since I do not know C. On that note any reason base64_encode/decode tests are under the url folder and not the strings folder in the php-src codebase 🤔. I wanted to put the tests for base32 beside those of base64 so it seems strange to me

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias I already wrote the implementation in PHP https://github.com/bakame-php/aide-base32/blob/main/Base32.php hence why I already have tests that I can backport from PHPUnit -> phpt

For the RFC I will copy/paste the draft I already wrote once the implementation is done in case we discover something we haven't thought about

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias I see base64_encode is getting an option argument to remove the padding ... should I already take this into consideration for base32_encode also or not ?

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias I updated my php codebase and remove all non string function except for array_key_exists and unpack I hope to create a PR to the php-src master with the tests ported hopefully first week of april. then I will ask for karma to create/ copy/paste my RFC for base32_(encode|decode) I might add the base32.h file but still checking how to write that one

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias
https://github.com/bakame-php/php-src/pull/1/files

Let me know if I am on the right track or not. I will then update the code accordingly I believe the base32.c will remain empty 😆

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias I see that.... Hope I'm not butchering the language

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias fixed your comment base32.c is populated with something 👌
Now only thing left is the C implementation I guess

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias anything I can do for the base32encode PR ? Only thing left is porting my PHP code to C and align it to php-src expectation I guess 😅

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias I'm going to try not sure about the result

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias I think I more or less was able to do base32_encode I'm still missing how I could rewrite this in C

$chars = (array) unpack('C*', $decoded);

Is there a way to call PHP implemetation of unpack directly 🤔 I presume there is but I have not found it or recognized it

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias
https://3v4l.org/iujGt

it converts the string characters into their byte representations and returns the result as an array

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias nice ... should then ease my conversion. will try to finish that one so you can see/review my horrible code. Once stable I will tackle the base32_decode which is more complex IMHO

nyamsprod, (edited )
@nyamsprod@phpc.social avatar

@derickr @Girgias https://github.com/bakame-php/php-src/pull/1/commits/61ab6aa33c6276b7eb8baea87578e8bd843b3c8e Added base32_encode .. you can take your red pen 😅 I'm pretty sure there are stuff that needs correction

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