{"id":924,"date":"2023-05-27T16:33:08","date_gmt":"2023-05-27T07:33:08","guid":{"rendered":"https:\/\/shinke1987.net\/?p=924"},"modified":"2023-05-27T16:33:09","modified_gmt":"2023-05-27T07:33:09","slug":"php%e3%81%a7%e3%81%ae%e4%be%8b%e5%a4%96%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=924","title":{"rendered":"PHP\u3067\u306e\u4f8b\u5916\u306b\u3064\u3044\u3066"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u4f8b\u5916\u30af\u30e9\u30b9<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td colspan=\"4\"><center><b>\u2190 \u89aa\u30af\u30e9\u30b9\u3000\u3000\u3000\u5b50\u30af\u30e9\u30b9 \u2192<\/b><\/center><\/td><td><center>\u6982\u8981<\/center><\/td><\/tr><tr><td rowspan=\"16\">Exception<\/td><td><\/td><td><\/td><td><\/td><td>\u3059\u3079\u3066\u306e\u4f8b\u5916\u306e\u57fa\u5e95\u30af\u30e9\u30b9\u3002<\/td><\/tr><tr><td>ErrorException<\/td><td><\/td><td><\/td><td>\u30a8\u30e9\u30fc\u4f8b\u5916\u3002<\/td><\/tr><tr><td rowspan=\"7\">LogicException<\/td><td><\/td><td><\/td><td>\u30ed\u30b8\u30c3\u30af\u306e\u8aa4\u308a\u3002<\/td><\/tr><tr><td rowspan=\"2\">BadFunctionCallException<\/td><td><\/td><td>\u95a2\u6570\u547c\u3073\u51fa\u3057\u306e\u554f\u984c\uff08\u672a\u5b9f\u88c5\u3001\u5f15\u6570\u4e0d\u8db3\u7b49\uff09<\/td><\/tr><tr><td>BadMethodCallException<\/td><td>\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u306e\u554f\u984c\uff08\u672a\u5b9f\u88c5\u3001\u5f15\u6570\u4e0d\u8db3\u7b49\uff09<\/td><\/tr><tr><td>DomainException<\/td><td><\/td><td>\u578b\u306f\u6b63\u3057\u3044\u304c\u5024\u304c\u4e0d\u6b63\u3002<\/td><\/tr><tr><td>InvalidArgumentException<\/td><td><\/td><td>\u5f15\u6570\u306e\u578b\u304c\u4e0d\u6b63\u3002<\/td><\/tr><tr><td>LengthException<\/td><td><\/td><td>\u9577\u3055\u304c\u4e0d\u6b63\u3002<\/td><\/tr><tr><td>OutOfRangeException<\/td><td><\/td><td>\u7121\u52b9\u306a\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3002<\/td><\/tr><tr><td rowspan=\"7\">RuntimeException<\/td><td><\/td><td><\/td><td>\u5b9f\u884c\u6642\u306e\u554f\u984c\u3002<\/td><\/tr><tr><td>OutOfBoundsException<\/td><td><\/td><td>\u914d\u5217\u30fb\u9023\u60f3\u914d\u5217\u306e\u30ad\u30fc\u304c\u4e0d\u6b63\u3002<\/td><\/tr><tr><td>OverflowException<\/td><td><\/td><td>\u3053\u308c\u4ee5\u4e0a\u8981\u7d20\u3092\u8ffd\u52a0\u3067\u304d\u306a\u3044\u3002<\/td><\/tr><tr><td>PDOException<\/td><td><\/td><td>PDO\u306b\u95a2\u308f\u308b\u554f\u984c\u3002<\/td><\/tr><tr><td>RangeException<\/td><td><\/td><td>\u578b\u306f\u6b63\u3057\u3044\u304c\u3001\u5024\u304c\u4e0d\u6b63\u3002<\/td><\/tr><tr><td>UnderflowException<\/td><td><\/td><td>\u3053\u308c\u4ee5\u4e0a\u8981\u7d20\u3092\u524a\u9664\u3067\u304d\u306a\u3044\u3002<\/td><\/tr><tr><td>UnexpectedValueException<\/td><td><\/td><td>\u623b\u308a\u5024\u304c\u4e0d\u6b63\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">\u72ec\u81ea\u306e\u4f8b\u5916\u30af\u30e9\u30b9<\/h2>\n\n\n\n<p>\u72ec\u81ea\u306e\u4f8b\u5916\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u306a\u3089\u3001\u6b21\u306e\u8981\u4ef6\u306b\u5f93\u3063\u3066\u304a\u304f\u3068\u826f\u3044\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Exception\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3059\u308b\u3053\u3068\u3002<\/li>\n\n\n\n<li>\u30af\u30e9\u30b9\u540d\u306e\u63a5\u5c3e\u8f9e\u306fException\u3068\u3059\u308b\u3053\u3068\u3002<\/li>\n\n\n\n<li>\u30a2\u30d7\u30ea\u304c\u8907\u6570\u306e\u4f8b\u5916\u3092\u6301\u3064\u5834\u5408\u306b\u306f\u3001\u30a2\u30d7\u30ea\u72ec\u81ea\u4f8b\u5916\u3092\u610f\u5473\u3059\u308b\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u7528\u610f\u3057\u3066\u304a\u304d\u3001\u4ed6\u306e\u4f8b\u5916\u306f\u3053\u308c\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3002\uff08\u30af\u30e9\u30b9\u3078\u306e\u30bf\u30b0\u4ed8\u3051\u3092\u76ee\u7684\u3068\u3057\u305f\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306e\u3053\u3068\u3092\u30de\u30fc\u30ab\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3068\u547c\u3093\u3060\u308a\u3059\u308b\uff09<\/li>\n<\/ol>\n\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">private\u30e1\u30bd\u30c3\u30c9\u3067\u306fassert\u6587\u3092try-catch\u6587\u306e\u4ee3\u308f\u308a\u306b\u4f7f\u3046<\/h2>\n\n\n\n<p>private\u30e1\u30bd\u30c3\u30c9\u306e\u3088\u3046\u306b\u3001\u547c\u3073\u51fa\u3057\u5143\u304c\u7279\u5b9a\u3055\u308c\u3066\u3044\u3066\u4fe1\u7528\u3067\u304d\u308b\u5834\u5408\u306f\u3001<br>\u691c\u67fb + \u4f8b\u5916\u30b9\u30ed\u30fc\u306e\u624b\u7d9a\u304d\u306f\u4e0d\u8981\u3002<br>\u4ee3\u308f\u308a\u306bassert\u6587\u3067\u5f15\u6570\u304c\u6e80\u305f\u3059\u3079\u304d\u6761\u4ef6\u3092\u5ba3\u8a00\u3059\u308b\u3068\u826f\u3044\u3002<br>assert\u547d\u4ee4\u306f\u6761\u4ef6\u304c\u6e80\u305f\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306b\u3001\u30a8\u30e9\u30fc\u30fb\u8b66\u544a\u3092\u6295\u3052\u308b\u3002<\/p>\n\n\n\n<p>\u4e0b\u8a18\u304c\u4f7f\u7528\u4f8b<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\nfunction getTest(int $i1, int $i2) : int {\n    assert($i1 &gt; 0 &amp;&amp; $i2 &gt; 0);\n    return $i1 + $i2;\n}\n<\/pre><\/div>\n\n\n<p>assert\u6587\u306fphp.ini\u3067\u52d5\u4f5c\u3092\u5909\u66f4\u3067\u304d\u308b\u3002\uff08\u4e0b\u8a18\u306fphp.ini\u3067\u306e\u9805\u76ee\u3068\u6982\u8981\uff09<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>zend.assertions<br>assert\u6587\u3092\u6709\u52b9\u306b\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u6c7a\u5b9a\u3059\u308b\u3002<br>\u8a2d\u5b9a\u5024 \u2192 1\uff1a\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3057\u3066\u5b9f\u884c\uff08\u958b\u767a\u30e2\u30fc\u30c9\u3002\u65e2\u5b9a\uff09<br>\u8a2d\u5b9a\u5024 \u2192 0\uff1a\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u304c\u3001\u5b9f\u884c\u6642\u306b\u306f\u30b9\u30ad\u30c3\u30d7\u3002<br>\u8a2d\u5b9a\u5024 \u2192 -1\uff1a\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3057\u306a\u3044\uff08\u672c\u756a\u30e2\u30fc\u30c9\uff09<\/li>\n\n\n\n<li>assert.exception<br>\u4f8b\u5916\u3092\u6295\u3052\u308b\u304b\u3069\u3046\u304b\u6c7a\u5b9a\u3059\u308b\u3002<br>\u8a2d\u5b9a\u5024 \u2192 0\uff1a\u8b66\u544a\u3092\u751f\u6210\uff08PHP 7.4 \u4ee5\u524d\u306e\u65e2\u5b9a\uff09<br>\u8a2d\u5b9a\u5024 \u2192 1\uff1aAssertError \u307e\u305f\u306f \u5f15\u6570$description \u306e\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\uff08PHP 8 \u4ee5\u964d\u306e\u65e2\u5b9a\uff09<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4f8b\u5916\u30af\u30e9\u30b9 \u2190 \u89aa\u30af\u30e9\u30b9\u3000\u3000\u3000\u5b50\u30af\u30e9\u30b9 \u2192 \u6982\u8981 Exception \u3059\u3079\u3066\u306e\u4f8b\u5916\u306e\u57fa\u5e95\u30af\u30e9\u30b9\u3002 ErrorException \u30a8\u30e9\u30fc\u4f8b\u5916\u3002 LogicException \u30ed\u30b8\u30c3\u30af\u306e\u8aa4\u308a\u3002 BadFunctionCall [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[81],"class_list":["post-924","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=924"}],"version-history":[{"count":2,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/924\/revisions"}],"predecessor-version":[{"id":926,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/924\/revisions\/926"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}