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

型で守るべき場所、守らなくていい場所 〜2015年のPHP内戦と言語設計の哲学〜

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for ずみ ずみ
March 19, 2026
27

型で守るべき場所、守らなくていい場所 〜2015年のPHP内戦と言語設計の哲学〜

Avatar for ずみ

ずみ

March 19, 2026
Tweet

Transcript

  1. ©Fusic Co., Ltd. 2 善住 直紘 C H I H

    I R O Y O S H I Z U M I 株式会社Fusic エンジニア 生まれも育ちも大阪府。中学時代に通ったプログラミングスクー ルがきっかけで情報分野に興味を持ち、情報系の大学に進学。 「面白そうな人たちが面白そうなことしてる」とFusicの個性に惹 かれ2025年4月に新卒入社。 自己紹介 はじめに @zumi_engineer ←福岡でPHPの勉強会を主催しています
  2. ©Fusic Co., Ltd. 7 PHP RFC: Scalar Type Declarations declare(strict_types=1);

    ↑RFCのページ↑ • スカラー型宣言(int、float、string、bool)を追加 • declare(strict_types=1);ディレクティブを追加 ↓ざっくり説明↓
  3. ©Fusic Co., Ltd. 10 declare(strict_types=1); ファイル単位 increment.php main.php Fatal error:

    Uncaught TypeError: increment(): Argument #1 ($a) must be of type int, string given, called in main.php on line 7 and defined in increment.php:3
  4. ©Fusic Co., Ltd. 15 なぜファイル単位で指定するのか Magical Quotesとは • 文字列を格納する際に、特殊文字を ”勝手にエスケープする

    ”機能 • 自分のPHPの設定でmagic_quotes_gpc = Off とオプトアウトしないとデフォルトで ”勝手に”エスケープする • 環境によって設定が異なるため、 Magical QuotesがONの想定で作ったパッ ケージがmagic_quotes_gpc = Offの環境で動くと予期しない動作が ...
  5. ©Fusic Co., Ltd. 18 strict_types スイッチは古いコードの移行メカニズムとして設計されたのではな く、どちらも同じように新しい 2 つの異なるオプション間の真の選択として設計さ れたのです。

    strict_types ディレクティブの背後にある考え方は、 2つのバージョンの機能を 1 つのシステムに統合し、ユーザーが自由に切り替えられるようにすることでし た。提案では、両方のモードにそれぞれ長所と短所があることが明確に示され ていました。 Re: strict_types will be default at some moment? 我々はどう使い分けるか https://news-web.php.net/php.internals/112232
  6. ©Fusic Co., Ltd. 22 declare(strict_types=1); declare(strict_types=1);とは... Fatal error: Uncaught TypeError:

    increment(): Argument #1 ($a) must be of type int, string given declare(strict_types=1);がある時 increment(“1”)