{"id":91,"date":"2023-06-02T11:13:54","date_gmt":"2023-06-02T09:13:54","guid":{"rendered":"https:\/\/extendsclass.com\/blog\/?p=91"},"modified":"2023-05-21T11:13:54","modified_gmt":"2023-05-21T09:13:54","slug":"php-8-3-new-features-and-release-date","status":"publish","type":"post","link":"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date","title":{"rendered":"PHP 8.3: new features and release date"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_47_1 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"ez-toc-toggle-icon-1\"><label for=\"item-69da84d087cd0\" aria-label=\"Table of Content\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;direction:ltr;\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input  type=\"checkbox\" id=\"item-69da84d087cd0\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#What_is_the_projected_release_date_for_PHP_83\" title=\" What is the projected release date for PHP 8.3?\"> What is the projected release date for PHP 8.3?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#json_validate\" title=\"json_validate()\">json_validate()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#Readonly_amendments\" title=\"Readonly amendments\">Readonly amendments<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#Dynamic_class_constant_fetch\" title=\"Dynamic class constant fetch\">Dynamic class constant fetch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#Improved_unserialize_error_handling\" title=\"Improved&nbsp;unserialize()&nbsp;error handling\">Improved&nbsp;unserialize()&nbsp;error handling<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#Randomizer_additions\" title=\"Randomizer additions\">Randomizer additions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#Typed_class_constants\" title=\"Typed class constants\">Typed class constants<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/extendsclass.com\/blog\/php-8-3-new-features-and-release-date\/#More_Appropriate_DateTime_Exceptions\" title=\"More Appropriate Date\/Time Exceptions\">More Appropriate Date\/Time Exceptions<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_the_projected_release_date_for_PHP_83\"><\/span><br>What is the projected release date for PHP 8.3?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>PHP 8.3 will be released on November 23, 2023. <\/p>\n\n\n\n<p>It&#8217;s coming, let&#8217;s see what&#8217;s new together.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"json_validate\"><\/span><code>json_validate()<\/code><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This new function called<code> json_validate() <\/code>validates if a string contains valid json. Instead of using&nbsp;<code>json_decode()<\/code>&nbsp;to validate a JSON string, you can now use&nbsp;<code>json_validate()<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>json_validate('{ \"test\": { \"foo\": \"bar\" } }');<\/code><\/pre>\n\n\n\n<p><code>json_validate()<\/code> takes <strong>less resources<\/strong> (memory and processing) than <code>json_decode()<\/code>.<\/p>\n\n\n\n<p class=\"has-text-align-center\">Learn more:&nbsp;<a href=\"https:\/\/wiki.php.net\/rfc\/json_validate\" target=\"_blank\" rel=\"noopener\" title=\"\"><code>json_validate()<\/code><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Readonly_amendments\"><\/span>Readonly amendments<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Readonly properties will be able to be reinitialized during cloning, throughout&nbsp;the execution of the&nbsp;<code>__clone()<\/code>&nbsp;magic method call. It is allow  deep cloning readonly properties.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Bar {\n    public function __construct(\n        public readonly DateTime $foo\n    ) {}\n \n    public function __clone()\n    {\n        $this-&gt;foo = clone $this-&gt;foo; \/\/ No error\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center\">Learn more:&nbsp;<a href=\"https:\/\/wiki.php.net\/rfc\/readonly_amendments\" target=\"_blank\" rel=\"noopener\" title=\"\"><code>Readonly amendments<\/code><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Dynamic_class_constant_fetch\"><\/span>Dynamic class constant fetch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>PHP implements various ways of looking up members name but this was not the case for the class constants.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Foo {\n    const BAR = 'bar';\n}\n$bar = 'BAR';\n \n\/\/ This is currently a syntax error\necho Foo::{$bar}; <\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center\">Learn more:&nbsp;<a href=\"https:\/\/wiki.php.net\/rfc\/dynamic_class_constant_fetch\" title=\"\">Dynamic class constant fetch<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Improved_unserialize_error_handling\"><\/span>Improved&nbsp;<code>unserialize()<\/code>&nbsp;error handling<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The error reporting in PHP&#8217;s <code>unserialize()<\/code> function is currently highly inconsistent, which makes it challenging to effectively handle errors that arise during the process of unserialization.<\/p>\n\n\n\n<p>The specific type of error triggered by a malformed input string in PHP can vary, leading to the generation of an E_NOTICE, an E_WARNING, or the throwing of an arbitrary <code>Exception<\/code> or <code>Error<\/code> (sometimes even a combination of these possibilities).<\/p>\n\n\n\n<ul>\n<li>Add wrapper Exception &#8216;UnserializationFailedException&#8217;: This enables to use a single&nbsp;<code>catch(\\UnserializationFailedException&nbsp;$e)<\/code>&nbsp;to catch all possible <code>Throwable<\/code>s&nbsp;<\/li>\n\n\n\n<li>Increase the error reporting severity in the unserialize() parser. <\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-align-center\">Learn more: <a href=\"https:\/\/wiki.php.net\/rfc\/improve_unserialize_error_handling\" title=\"\">Improved unserialize() error handling<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Randomizer_additions\"><\/span>Randomizer additions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Three new methods will be added  to <code>\\Random\\Randomizer<\/code> and one enum. These methods implement commonly useful operations that are either verbose or very difficult to implement.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace Random;\n \nfinal class Randomizer {\n    \/\/ &#91;\u2026]\n    public function getBytesFromString(string $string, int $length): string {}\n    public function nextFloat(): float {}\n    public function getFloat(\n        float $min,\n        float $max,\n        IntervalBoundary $boundary = IntervalBoundary::ClosedOpen\n    ): float {}\n}\n \nenum IntervalBoundary {\n    case ClosedOpen;\n    case ClosedClosed;\n    case OpenClosed;\n    case OpenOpen;\n}<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center\">Learn more:&nbsp;<a href=\"https:\/\/wiki.php.net\/rfc\/randomizer_additions\" target=\"_blank\" rel=\"noopener\" title=\"\">Randomizer Additions<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Typed_class_constants\"><\/span>Typed class constants<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>PHP 8.3 will finally introduce typed class constants! This new feature aims to minimize bugs and confusion that often arise when child classes override constants from parent classes.<\/p>\n\n\n\n<p>Typed class constants can now be declared in various entities, including classes, interfaces, traits, and enums.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>enum E {\n    const string BAR = \"Test1\";\n}\n \ntrait T {\n    const string BAR = E::BAR;\n}\n \ninterface I {\n    const string BAR = E::BAR;\n}\n \nclass C implements I { \n    const string BAR = E::BAR;\n}<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center\">Learn mode: <a href=\"https:\/\/wiki.php.net\/rfc\/typed_class_constants\" title=\"\">Typed class constants<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"More_Appropriate_DateTime_Exceptions\"><\/span>More Appropriate Date\/Time Exceptions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Specific exceptions and errors for Date\/Time extensions are added, where this makes sense.<\/p>\n\n\n\n<p>Currently, there are warnings\/errors or generic &#8220;Exception&#8221; or &#8220;Error&#8221; types. This lack of specificity makes it difficult to catch Date\/Time exceptions effectively.<\/p>\n\n\n\n<p class=\"has-text-align-center\">Learn more:<a href=\"https:\/\/wiki.php.net\/rfc\/datetime-exceptions\" title=\"\"> More Appropriate Date\/Time Exceptions<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>This page lists all the current RFCs for <a href=\"https:\/\/wiki.php.net\/rfc#php_83\">PHP 8.3<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP 8.3 will be released on November 23, 2023; It&#8217;s coming, let&#8217;s see what&#8217;s new together.<\/p>\n","protected":false},"author":1,"featured_media":114,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":""},"categories":[2],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/91"}],"collection":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":21,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/91\/revisions\/93"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/media\/114"}],"wp:attachment":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}