Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHPのスカラー型をクラスでラップして便利に使えるようにするライブラリ「Stannum」を作った話

3439e59c30a7b1ab30af827193b93621?s=47 tumugin.myskng
April 11, 2022
230

 PHPのスカラー型をクラスでラップして便利に使えるようにするライブラリ「Stannum」を作った話

3439e59c30a7b1ab30af827193b93621?s=128

tumugin.myskng

April 11, 2022
Tweet

Transcript

  1. Copyright© M&A PHP Stannum PHPerKaigi 2 0 2 2

  2. Copyright© M&A 2 M&A Twitter: @myskng (Twitter ... ...) GitHub:

    @tumugin PHP(Laravel) JavaScript TypeScript(Vue) ( Ruby Kotlin ...)
  3. Copyright© M&A 3

  4. Copyright© M&A 4

  5. Copyright© M&A 5 ) , , , , , ,,

    ,,, ... string string
  6. Copyright© M&A 6 ( ...) ( UI )

  7. Copyright© M&A Ruby 7 ....? ' , , , ,

    , ,, ,,,' .split(',') .filter { |s| !s.strip.empty? } .map { |s| s.strip } .uniq => [" ", " ", " ", " "] PHP ....( )
  8. Copyright© M&A PHP 8 PHP ... $inputTags = ' ,

    , , , , ,, ,,,'; $splitTags = explode(',', $inputTags); $splitTagsWithoutEmpty = []; foreach ($splitTags as $tag) { if (trim($tag) !== '') { $splitTagsWithoutEmpty[] = trim($tag); } } $splitTagsWithoutEmptyAndDuplicate = array_unique($splitTagsWithoutEmpty); ...? ....?
  9. Copyright© M&A PHP 9 array_unique( array_map( fn(string $s) => trim($s),

    array_filter( explode(',', ' , , , , , ,,, ,,'), fn(string $s) => trim($s) !== '' ) ) ); ...😇 😇 😇
  10. Copyright© M&A 10 🥺🥺🥺

  11. Copyright© M&A 11

  12. Copyright© M&A 12

  13. Copyright© M&A 13

  14. Copyright© M&A 14 extension (nikic/scalar_objects) - ... - PHP

  15. Copyright© M&A 15 RFCs PHP RFC: Autoboxing https://wiki.php.net/rfc/autoboxing PHP RFC:

    Class-like Primitive Types https://wiki.php.net/rfc/class-like_primitive_types ...
  16. Copyright© M&A 16 ...🥺🥺

  17. Copyright© M&A 17 ...

  18. Copyright© M&A 18 💡💡💡💡

  19. Copyright© M&A 19

  20. Copyright© M&A 20 ... tumugin/stannum PHP 7 . 4 (

    array) float/double integer string Sn => Stannum( )
  21. Copyright© M&A 21 SnString::byString(' , , , , , ,,

    ,,,') ->split(',') ->filter(fn(SnString $s) => !$s->trim()->isEmpty()) ->map(fn(SnString $s) => $s->trim()) ->distinct() ->toSnStringList() ->toStringArray(); ... PHP
  22. Copyright© M&A 22 PHP ...?

  23. Copyright© M&A ... foreach ...? 23 $sushiList = SnStringList::byStringArray([ '

    ', ' ', ' ', ' ', ' ', ]); foreach ($sushiList as $sushi) { // something... }
  24. Copyright© M&A __toString() ...? 24 $wantToEatSushi = SnString::byString( ' '

    ); return "{$wantToEatSushi} "; =>
  25. Copyright© M&A 25

  26. Copyright© M&A 26 composer require tumugin/stannum