@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 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

@Girgias @derickr added support for the padding character. base32_encode may now also return false if the submitted alphabet or padding is invalid.

nyamsprod,
@nyamsprod@phpc.social avatar

@Girgias @derickr I have a polyfill in which I do throw an exception but PHP function do not throw exception normally unless in this case it becomes possible to do so. https://github.com/bakame-php/aide-base32

nyamsprod,
@nyamsprod@phpc.social avatar

@Girgias @derickr so ValueError for alphabet and padding and false for everything else concerning decoding then .. noted I will change the wording then. And it makes encoding always returning a string which is better.

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, to random French
@nyamsprod@phpc.social avatar

Last night I published league/csv version 9.15.0 https://github.com/thephpleague/csv/releases/tag/9.15.0 I hope it will be the first and last release this year (aside any security and bug releases).. I think it will take time for people to adapt to all the new shiny things that landed in the package the past year.

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

@thepanz I think this can be considred a fix and nor a new feature AFAIK also I think I already updated the docblocs to this https://github.com/thephpleague/csv/blob/master/src/Reader.php#L455-L466

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

When getting an Iterator as returned by a function/method do you expect the Iterator to already be rewinded or not ? Asking because in this assumption is never guaranteed by any contract 🤔

nyamsprod,
@nyamsprod@phpc.social avatar

@ocramius asking because I got this issue on CSV and I am going back in forth in saying its not a bug or it is ... to me it is not https://github.com/thephpleague/csv/issues/514 so I should not fix it IMHO or should I

nyamsprod,
@nyamsprod@phpc.social avatar

@zimzat @ocramius
My general advice/recommendation is if you have an Iterator either use the foreach construct or iterator_to_array or indeed use IteratorAggregate. You should never directly use the current method of the interface

nyamsprod,
@nyamsprod@phpc.social avatar

@zimzat @ocramius
For context, the class already exposes the IteratorAggregate interface but the getRecords method is needed for cases where using the interface is not possible (ie if more options are needed to calculate the records)

nyamsprod, (edited ) to random French
@nyamsprod@phpc.social avatar

to honour
@fredbouchery what will be display ? #phpquiz
echo date('Y-m-d H:i:s', strtotime('')), PHP_EOL;

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

I wish #PHP had two things and none of them involve generics... I wish it had type aliases and a native base32 encoding/decoding mechanism (in a class or a pair of functions I do not care)

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias no problem take your time I wanted to put my thoughts into words before the break and yes the proposal can evolve

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias did you have a chance to check how Python did it ? They use to have functions with signature similar to our current base64 approach but they did revamp the API https://docs.python.org/3/library/base64.html
Again I am not sure as you said that all should be covered but I believe being able to encode/decode hex and ascii should be possible natively

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias If we stick with functions a la base64 we then need to add extra variables - the alphabet and maybe the padding character. so that user land can switch the alphabet and/or the padding character as they want PHP would only provide the Hex and Us-Ascii alphabet (those from the RFC)
So for encoding you would have at most 3 parameters and 4 on decode.

nyamsprod,
@nyamsprod@phpc.social avatar

@derickr @Girgias following our last discussion I createed a polyfill using functions only let me know if this is what you had in mind. https://github.com/bakame-php/aide/tree/main/src/Base32
The implementation does not really matter what matter most is the API

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