[dokuwiki] New PR: introduce sexplode() as a PHP8 safe explode()

  • From: "splitbrain" <wiki@xxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 26 Aug 2022 11:05:24 +0200 (CEST)

Hi,

splitbrain opened a new pull request at 
https://github.com/splitbrain/dokuwiki/pull/3754:

We often have constructs like

```php
list($foo, $bar) = explode(',', $input, 2);
```

In PHP8+ this will throw warnings when the explode returns fewer than 2 
elements. Our code usually (always?) will anticipate missing elements so the 
construct isn't really problematic.

The implementation here wraps the solution suggested at 
https://stackoverflow.com/a/56971347 into a new utility function.

I anticipate that people might object to the function name. It was chosen as a 
short form of "safe explode". This makes fixing the warning easy by simply 
adding a single letter. I also find it slightly amusing and would be open to 
change it to just sex() just for the fun of it.

Please help us to review this pull request, so new contributors get feedback in 
a timely manner.

37187630-251e-11ed-9dca-8a625b2b3411


-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts:

  • » [dokuwiki] New PR: introduce sexplode() as a PHP8 safe explode() - splitbrain