[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"docs:\u002Fdocs\u002Flanguage\u002Fstrings":3},"\u003Cp>PHP has one string type for two different things: text, such as a name or a JSON document, and\nbinary data, such as a hash, a random token or a packed frame. Phaenon gives the second its own\ntype, \u003Ccode>bytes\u003C\u002Fcode>, so that a random token is not echoed into HTML or compared with a password by\naccident. At run time both are PHP strings, and \u003Ccode>bytes\u003C\u002Fcode> compiles to \u003Ccode>string\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ch2 id=\"at-a-glance\">At a glance\u003Ca class=\"docs-anchor\" href=\"#at-a-glance\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cdiv class=\"docs-example\">\u003Cfigure class=\"docs-code phn-code-surface\">\u003Cfigcaption class=\"docs-code-head\">\u003Cspan class=\"docs-code-label\">you write\u003C\u002Fspan>\u003C\u002Ffigcaption>\u003Cdiv class=\"docs-code-body\">\u003Cpre class=\"shiki shiki-themes phaenon-light phaenon-dark\" style=\"--phn-light:#1f2127;--phn-dark:#e2e3e7;--phn-light-bg:#f9fafb;--phn-dark-bg:#0f1115\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">namespace\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> App\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">final\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> class\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> Token\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">{\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\">    __construct\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">private\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> bytes\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">)\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> {}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    static\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> generate\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">():\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> self\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> =>\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> new\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> self\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\">random_bytes\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\">16\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">));\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    static\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> fromHeader\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $header\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">):\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\"> ?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">self\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">        $raw \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">=\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> base64_decode\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$header\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">,\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\"> true\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">        return\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">===\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\"> false\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> ?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\"> null\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> :\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> new\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> self\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">((\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">bytes\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">)\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\">    hex\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">():\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> =>\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> bin2hex\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-light-font-style:italic;--phn-dark:#E2E3E7;--phn-dark-font-style:italic\">this\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">->\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Ffigure>\n\u003Cfigure class=\"docs-code phn-code-surface\">\u003Cfigcaption class=\"docs-code-head\">\u003Cspan class=\"docs-code-label\">phn build writes\u003C\u002Fspan>\u003C\u002Ffigcaption>\u003Cdiv class=\"docs-code-body\">\u003Cpre class=\"shiki shiki-themes phaenon-light phaenon-dark\" style=\"--phn-light:#1f2127;--phn-dark:#e2e3e7;--phn-light-bg:#f9fafb;--phn-dark-bg:#0f1115\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\">php\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7C;--phn-light-font-style:italic;--phn-dark:#7D8393;--phn-dark-font-style:italic\">\u002F* @generated by phaenon from Example.phn *\u002F\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">declare\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\">strict_types\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">=\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\">1\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">namespace\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> App\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">final\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> class\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> Token\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">{\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    public\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> function\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> __construct\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">private\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">)\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> {}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    public\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> static\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> function\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> generate\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">():\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> self\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">    {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">        return\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> new\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> self\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\">random_bytes\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\">16\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">));\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    public\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> static\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> function\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> fromHeader\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $header\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">):\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\"> ?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">self\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">    {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">        $raw \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">=\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> base64_decode\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$header\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">,\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\"> true\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">        return\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">===\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\"> false\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> ?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\"> null\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> :\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> new\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> self\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    public\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> function\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> hex\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">():\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> string\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">    {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">        return\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> bin2hex\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-light-font-style:italic;--phn-dark:#E2E3E7;--phn-dark-font-style:italic\">this\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">->\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Ffigure>\n\u003C\u002Fdiv>\n\u003Cp>\u003Ccode>random_bytes()\u003C\u002Fcode> returns \u003Ccode>bytes\u003C\u002Fcode>, \u003Ccode>bin2hex()\u003C\u002Fcode> takes it and returns text, and \u003Ccode>(bytes)\u003C\u002Fcode> says that\nwhat \u003Ccode>base64_decode()\u003C\u002Fcode> returned is binary. The cast leaves nothing in the PHP.\u003C\u002Fp>\n\u003Ch2 id=\"two-types-neither-a-subtype-of-the-other\">Two types, neither a subtype of the other\u003Ca class=\"docs-anchor\" href=\"#two-types-neither-a-subtype-of-the-other\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cp>\u003Ccode>string\u003C\u002Fcode> is text, UTF-8. \u003Ccode>bytes\u003C\u002Fcode> is binary data of any length. A \u003Ccode>bytes\u003C\u002Fcode> value does not go where\na \u003Ccode>string\u003C\u002Fcode> is expected, nor the other way, and the checker reports what would mix them:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Ccode>.\u003C\u002Fcode> joins two values of the same kind: \u003Ccode>string . string\u003C\u002Fcode> is text, \u003Ccode>bytes . bytes\u003C\u002Fcode> is binary.\nJoining one with the other is \u003Ccode>P2530\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>Interpolation, \u003Ccode>&quot;id: $raw&quot;\u003C\u002Fcode>, and \u003Ccode>echo\u003C\u002Fcode> take text only: a \u003Ccode>bytes\u003C\u002Fcode> operand is \u003Ccode>P2530\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Ccode>===\u003C\u002Fcode> between a \u003Ccode>string\u003C\u002Fcode> and a \u003Ccode>bytes\u003C\u002Fcode> is \u003Ccode>P2305\u003C\u002Fcode>. Both are PHP strings and may compare equal,\nbut comparing text with binary is a mistake in the code.\u003C\u002Fli>\n\u003Cli>A string literal is \u003Ccode>string\u003C\u002Fcode>. There is no bytes literal: a binary buffer starts from\n\u003Ccode>(bytes) &#39;&#39;\u003C\u002Fcode>, and \u003Ccode>$buffer .= $chunk\u003C\u002Fcode> keeps it \u003Ccode>bytes\u003C\u002Fcode>.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cdiv class=\"docs-example\">\u003Cfigure class=\"docs-code phn-code-surface\">\u003Cfigcaption class=\"docs-code-head\">\u003Cspan class=\"docs-code-label\">you write\u003C\u002Fspan>\u003C\u002Ffigcaption>\u003Cdiv class=\"docs-code-body\">\u003Cpre class=\"shiki shiki-themes phaenon-light phaenon-dark\" style=\"--phn-light:#1f2127;--phn-dark:#e2e3e7;--phn-light-bg:#f9fafb;--phn-dark-bg:#0f1115\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">namespace\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> App\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">function\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> header\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">bytes\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $frame\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">,\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $name\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">):\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">    $line \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">=\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#2A7A4B;--phn-dark:#8FD3A3\"> \"frame for \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$name\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#2A7A4B;--phn-dark:#8FD3A3\">: \"\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> .\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $frame\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    return\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $frame \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\">===\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $name \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $line \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">:\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#2A7A4B;--phn-dark:#8FD3A3\"> ''\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Ffigure>\n\u003Cfigure class=\"docs-code phn-code-surface docs-code-diag\">\u003Cfigcaption class=\"docs-code-head\">\u003Cspan class=\"docs-code-file\">$ phn check\u003C\u002Fspan>\u003Cspan class=\"docs-code-label\">exit 1\u003C\u002Fspan>\u003C\u002Ffigcaption>\u003Cdiv class=\"docs-code-body\">\u003Cpre class=\"phn-diag\">\u003Ccode>\u003Cspan class=\"line head\">\u003Cspan class=\"diag-where\">src\u002FExample.phn:4:13\u003C\u002Fspan>: \u003Cspan class=\"diag-error\">error\u003C\u002Fspan> \u003Cspan class=\"diag-code\">P2530\u003C\u002Fspan>: \u003Cspan class=\"diag-message\">cannot concatenate bytes and text: mb_check_encoding($frame, 'UTF-8') checks the bytes are UTF-8 text, after which they are string&amp;bytes and join text; (string) $frame converts them unchecked; (bytes) takes text as its UTF-8 bytes, and (bytes) '' starts a binary buffer\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan class=\"diag-gutter\">    4 |\u003C\u002Fspan>     $line = &quot;frame for $name: &quot; . $frame;\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan class=\"diag-gutter\">      |\u003C\u002Fspan>             \u003Cspan class=\"diag-caret\">^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line head\">\u003Cspan class=\"diag-where\">src\u002FExample.phn:6:12\u003C\u002Fspan>: \u003Cspan class=\"diag-error\">error\u003C\u002Fspan> \u003Cspan class=\"diag-code\">P2305\u003C\u002Fspan>: \u003Cspan class=\"diag-message\">strict comparison between bytes and string compares binary data with text, which may still hold the same bytes: write (bytes) on the text to compare bytes, or test mb_check_encoding($frame, 'UTF-8') first to compare text (the bytes are string&amp;bytes after it)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan class=\"diag-gutter\">    6 |\u003C\u002Fspan>     return $frame === $name ? $line : '';\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan class=\"diag-gutter\">      |\u003C\u002Fspan>            \u003Cspan class=\"diag-caret\">^^^^^^^^^^^^^^^^\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan class=\"diag-summary\">1 files checked: 2 errors, 0 warnings\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Ffigure>\n\u003C\u002Fdiv>\n\u003Ch2 id=\"converting\">Converting\u003Ca class=\"docs-anchor\" href=\"#converting\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cdiv class=\"docs-table\">\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>From\u003C\u002Fth>\u003Cth>To\u003C\u002Fth>\u003Cth>Write\u003C\u002Fth>\u003Cth>At run time\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>\u003Ccode>string\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>bytes\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>(bytes) $text\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>nothing: the cast is erased\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>\u003Ccode>bytes\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>string\u003C\u002Fcode>, unchecked\u003C\u002Ftd>\u003Ctd>\u003Ccode>(string) $raw\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>nothing\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>\u003Ccode>bytes\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>string\u003C\u002Fcode>, checked\u003C\u002Ftd>\u003Ctd>\u003Ccode>mb_check_encoding($raw, &#39;UTF-8&#39;)\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>the test, which PHP runs\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>\u003Ccode>bytes\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>string\u003C\u002Fcode>, lossy\u003C\u002Ftd>\u003Ctd>\u003Ccode>mb_scrub($raw)\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>invalid sequences replaced\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>\u003Ccode>bytes\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>hex or base64 text\u003C\u002Ftd>\u003Ctd>\u003Ccode>bin2hex($raw)\u003C\u002Fcode>, \u003Ccode>base64_encode($raw)\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>the encoding\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003C\u002Fdiv>\n\u003Cp>\u003Ccode>(bytes)\u003C\u002Fcode> retypes text, or a \u003Ccode>string\u003C\u002Fcode> that a PHP function returned with binary in it, as binary\ndata. \u003Ccode>(string)\u003C\u002Fcode> is the way back for an API that takes binary in a \u003Ccode>string\u003C\u002Fcode> parameter, such as a\nUUID library&#39;s \u003Ccode>fromBinary(string $bytes)\u003C\u002Fcode>: the cast shows in the code where binary crosses into\na \u003Ccode>string\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>The checked way is PHP&#39;s own test. Where \u003Ccode>mb_check_encoding($raw, &#39;UTF-8&#39;)\u003C\u002Fcode> holds, the checker\nnarrows \u003Ccode>$raw\u003C\u002Fcode> to \u003Ccode>string&amp;bytes\u003C\u002Fcode>, a value that is both, accepted wherever either is:\u003C\u002Fp>\n\u003Cfigure class=\"docs-code phn-code-surface\">\u003Cdiv class=\"docs-code-body\">\u003Cpre class=\"shiki shiki-themes phaenon-light phaenon-dark\" style=\"--phn-light:#1f2127;--phn-dark:#e2e3e7;--phn-light-bg:#f9fafb;--phn-dark-bg:#0f1115\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">namespace\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> App\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">function\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> text\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">bytes\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">):\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\"> string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">    return\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> mb_check_encoding\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">,\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#2A7A4B;--phn-dark:#8FD3A3\"> 'UTF-8'\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">)\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> ?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">:\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> throw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\"> new\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> \\\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">ValueError\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#2A7A4B;--phn-dark:#8FD3A3\">'not valid UTF-8'\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--phn-light:#8F5E00;--phn-dark:#F2B43F\">function\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> textOrNull\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">bytes\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">):\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#474C5A;--phn-dark:#B1B6C4\"> ?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#0D5F78;--phn-dark:#6FC3DF\">string\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> =>\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#7A3D99;--phn-dark:#C9A0F0\"> mb_check_encoding\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">(\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\">$raw\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">,\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#2A7A4B;--phn-dark:#8FD3A3\"> 'UTF-8'\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">)\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\"> ?\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#1F2127;--phn-dark:#E2E3E7\"> $raw \u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">:\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#B4431A;--phn-dark:#F29D6B\"> null\u003C\u002Fspan>\u003Cspan style=\"--phn-light:#6A6F7D;--phn-dark:#8B91A2\">;\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Ffigure>\n\u003Cp>The encoding must be a literal naming UTF-8. The test needs the \u003Ccode>mbstring\u003C\u002Fcode> extension, or\n\u003Ccode>symfony\u002Fpolyfill-mbstring\u003C\u002Fcode>, as any \u003Ccode>mb_*\u003C\u002Fcode> call does.\u003C\u002Fp>\n\u003Ch2 id=\"phps-functions\">PHP&#39;s functions\u003Ca class=\"docs-anchor\" href=\"#phps-functions\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cp>The functions that produce binary are typed \u003Ccode>bytes\u003C\u002Fcode>: \u003Ccode>random_bytes()\u003C\u002Fcode>, \u003Ccode>hash(…, binary: true)\u003C\u002Fcode>,\n\u003Ccode>hash_hmac(…, binary: true)\u003C\u002Fcode>, \u003Ccode>md5(…, true)\u003C\u002Fcode>, \u003Ccode>sha1(…, true)\u003C\u002Fcode>, \u003Ccode>pack()\u003C\u002Fcode>,\n\u003Ccode>openssl_random_pseudo_bytes()\u003C\u002Fcode>, and \u003Ccode>hex2bin()\u003C\u002Fcode>, which returns \u003Ccode>bytes|false\u003C\u002Fcode>. The functions that\nserve text and binary alike take either: \u003Ccode>strlen()\u003C\u002Fcode>, \u003Ccode>substr()\u003C\u002Fcode> (which returns what it was\ngiven), \u003Ccode>strcmp()\u003C\u002Fcode>, \u003Ccode>ord()\u003C\u002Fcode>, \u003Ccode>hash_equals()\u003C\u002Fcode>, \u003Ccode>fwrite()\u003C\u002Fcode>, \u003Ccode>file_put_contents()\u003C\u002Fcode>, \u003Ccode>bin2hex()\u003C\u002Fcode>,\n\u003Ccode>base64_encode()\u003C\u002Fcode>. A function meant for text, such as \u003Ccode>strtoupper()\u003C\u002Fcode>, takes a \u003Ccode>string\u003C\u002Fcode> only.\u003C\u002Fp>\n\u003Cp>Some functions return a \u003Ccode>string\u003C\u002Fcode> that may be either, and keep PHP&#39;s type: \u003Ccode>base64_decode()\u003C\u002Fcode>,\n\u003Ccode>file_get_contents()\u003C\u002Fcode> and \u003Ccode>fread()\u003C\u002Fcode>. Write \u003Ccode>(bytes)\u003C\u002Fcode> where you know the result is binary.\u003C\u002Fp>\n\u003Ch2 id=\"what-the-checker-reports\">What the checker reports\u003Ca class=\"docs-anchor\" href=\"#what-the-checker-reports\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cdiv class=\"docs-table\">\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>Code\u003C\u002Fth>\u003Cth>When\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>\u003Ccode>P2530\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>bytes\u003C\u002Fcode> used as text: joined with a \u003Ccode>string\u003C\u002Fcode>, interpolated, echoed\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>\u003Ccode>P2305\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>===\u003C\u002Fcode> or \u003Ccode>!==\u003C\u002Fcode> between \u003Ccode>string\u003C\u002Fcode> and \u003Ccode>bytes\u003C\u002Fcode>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>\u003Ccode>P2103\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>bytes\u003C\u002Fcode> passed where a \u003Ccode>string\u003C\u002Fcode> is declared, or the reverse\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003C\u002Fdiv>\n\u003Cp>Where the two compare identical, \u003Ccode>if ($frame === $name)\u003C\u002Fcode>, both are \u003Ccode>string&amp;bytes\u003C\u002Fcode> in that\nbranch, as after \u003Ccode>mb_check_encoding()\u003C\u002Fcode>: the code there is checked with that type.\u003C\u002Fp>\n\u003Ch2 id=\"in-the-compiled-php\">In the compiled PHP\u003Ca class=\"docs-anchor\" href=\"#in-the-compiled-php\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cp>\u003Ccode>bytes\u003C\u002Fcode> is \u003Ccode>string\u003C\u002Fcode> in signatures and docblocks alike, so \u003Ccode>list&lt;bytes&gt;\u003C\u002Fcode> becomes \u003Ccode>list&lt;string&gt;\u003C\u002Fcode>\nfor PHPStan, which has no binary type. \u003Ccode>(bytes)\u003C\u002Fcode> is removed; \u003Ccode>(string)\u003C\u002Fcode> stays, as PHP&#39;s own\ncast. A PHP caller sees \u003Ccode>string\u003C\u002Fcode> parameters and can pass any string: the distinction is checked\nin Phaenon code only.\u003C\u002Fp>\n\u003Ch2 id=\"migrating\">Migrating\u003Ca class=\"docs-anchor\" href=\"#migrating\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cp>\u003Ccode>phn migrate\u003C\u002Fcode> cannot know which strings hold binary data, so every \u003Ccode>string\u003C\u002Fcode> stays a \u003Ccode>string\u003C\u002Fcode>. The\nchecker then points at the places to change: a \u003Ccode>random_bytes()\u003C\u002Fcode> stored in a \u003Ccode>string\u003C\u002Fcode> property is\nthe typical first finding, which is fixed by typing the property \u003Ccode>bytes\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ch2 id=\"see-also\">See also\u003Ca class=\"docs-anchor\" href=\"#see-also\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>\u003Ca href=\"\u002Fdocs\u002Flanguage\u002Fnarrowing\">Type tests and narrowing\u003C\u002Fa>, for \u003Ccode>mb_check_encoding()\u003C\u002Fcode> and the other\ntests\u003C\u002Fli>\n\u003Cli>\u003Ca href=\"\u002Fdocs\u002Flanguage\u002Foverview\">Phaenon for PHP developers\u003C\u002Fa>\u003C\u002Fli>\n\u003C\u002Ful>\n",1794925619400]