Avatar
😀
1 results for Go
  • PHP8.5がくるらしい

    TL;DR

    これを読みなさい

    https://stitcher.io/blog/new-in-php-85

    パイプ演算子

    $input = ' Some kind of string. ';
    
    $output = strtolower(
        str_replace(['.', '/', '…'], '',
            str_replace(' ', '-',
                trim($input)
            )
        )
    );
    

    $output = $input 
        |> trim(...)
        |> (fn (string $string) => str_replace(' ', '-', $string))
        |> (fn (string $string) => str_replace(['.', '/', '…'], '', $string))
        |> strtolower(...);
    

    おしゃれ ただ結果記述長くなる場合がありそうだし、phpの->methodみたいに呼出すのをヘルパーとかでやるのはどうなんだろ 好みが分かれそう

    より詳細

    Clone with

    final class Book
    {
        public function __construct(
            public string $title,
            public string $description,
        ) {}
        
        public function withTitle(string $title): self
        {
            return clone($this, [
                'title' => $title,
            ]);
        }
    }
    

    🙄

    go php エラー対応 Created Mon, 17 Nov 2025 10:34:30 +0000