Maximize your Laravel blog's potential with SEO best practices and reach 10K monthly clicks on Google.
Preview the course for free
Benjamin Crozat New!
Benjamin Crozat The art of crafting web applications

PHP 8.3: new features (with RFCs) and release date.

Benjamin Crozat — Updated on
Artboard

Hundreds of developers subscribed to my newsletter.
Join them and enjoy free content about the art of crafting websites!

Powered by

PHP is an open-source project. Knowing what’s going on for the next version only takes a minute of research. For instance, this page lists all the accepted RFCs for PHP 8.3.

Below, you will find a condensed list of what’s new, with code samples that make sense.

Table of contents

PHP 8.3: new features (with RFCs) and release date.

When will PHP 8.3 be released?

According to the preparation tasks list, PHP 8.3 will be released on November 23, 2023, after three alpha releases, three beta, and six release candidates.

Date Release
June 8, 2023 Alpha 1
June 22, 2023 Alpha 2
July 6, 2023 Alpha 3
July 18, 2023 Feature freeze
July 20, 2023 Beta 1
August 03, 2023 Beta 2
August 17, 2023 Beta 3
August 31, 2023 RC 1
September 14, 2023 RC 2
September 28, 2023 RC 3
October 12, 2023 RC 4
October 26, 2023 RC 5
November 9, 2023 RC 6
November 23, 2023 GA

What’s new in PHP 8.3: new features and changes

json_validate()

Instead of using json_decode() to validate a JSON string, you can now use json_validate(). According to its RFC, it also consumes fewer resources.

json_validate('{ "foo": "bar", }');
 
// Syntax error
echo json_last_error_msg();

As you can see, json_validate() returns a boolean, and you can fetch the error message with json_last_error() or json_last_error_msg() for more details.

Learn more: PHP RFC: json_validate

Improved unserialize() error handling

This proposal aims to improve the error handling in PHP’s unserialize() function, which is inconsistent and hard to handle reliably.

Depending on the input string, PHP 8.2 may emit an E_NOTICE, an E_WARNING, or throw an arbitrary exception or fatal error.

This can make it challenging for developers to manage errors that occur during unserialization.

The proposed solution has two parts:

Learn more: PHP RFC: Improve unserialize() error handling

Randomizer additions

This RFC proposes to add three new methods to \Random\Randomizer and an enum called IntervalBoundary, which is used in one of the methods:

final class Randomizer {
public function getBytesFromString(string $string, int $length) : string {}
public function nextFloat() : float {}
public function getFloat(float $min, float $max, IntervalBoundary $boundary = IntervalBoundary::ClosedOpen) : float {}
}
 
enum IntervalBoundary
{
case ClosedOpen;
case ClosedClosed;
case OpenClosed;
case OpenOpen;
}

Learn more: PHP RFC: Randomizer Additions

Dynamic class constant fetch

This RFC proposes to allow class constants to be accessed dynamically using variables.

Instead of accessing class constants with a static string value (e.g. ClassName::CONSTANT), you could use a variable containing the constant name.

$constant = 'CONSTANT';
 
ClassName::{$constant}

This change would make it easier to access class constants dynamically and programmatically.

Learn more: PHP RFC: Dynamic class constant fetch

More appropriate Date/Time exceptions

The RFC proposes introducing specific date and time exceptions in PHP where it makes sense.

Currently, there are warnings, errors or a basic “Exception”, which are not specific enough.

There will be different exceptions for errors, such as DateInvalidTimeZoneException, DateInvalidOperationException, and DateMalformedStringException.

Learn more: PHP RFC: More Appropriate Date/Time Exceptions

Read only amendments

In PHP 8.2, you couldn’t lift the restriction when extending a readonly class.

Here’s an example:

readonly class A {}
 
// Fatal error: Non-readonly class B cannot extend readonly class A
class B extends A {}

Starting from PHP 8.3, this won’t throw a fatal error anymore. 👍

However, the inverse still remains as it is.

class A {}
 
// Fatal error: Readonly class B cannot extend non-readonly class A
readonly class B extends A {}

Learn more: PHP RFC: Read only amendements


That’s it for PHP 8.3 so far. 👍

I will report every newly accepted RFC in the coming months!

Subscribe to my newsletter and follow me on Twitter to make sure you don’t miss anything!

Recommended

Learn why and how to fix "Methods with the same name as their class will not be constructors in a future version of PHP" warnings.

Take your code to the next level, thanks to exceptions. Handle errors in a more graceful way within try and catch blocks.

Learning a framework can be overwhelming, but time and execution will make you a master. Here are some best practices to help you toward your goal.

Nailing a Laravel job interview can be a daunting task, but with the right preparation and mindset, you can set yourself up for success.

Laravel 10 has been released on February 14, 2023. Let's dive into every relevant new feature and change.

I show you how to upgrade your Laravel 8 project to version 9 and help you decide whether the return on investment is worth it.

Here's a case study for my blog in the programming niche, where I share everything I did to increase clicks by a huge amount since the beginning.

I show you how to upgrade your Laravel 9 project to version 10 and help you decide whether the return on investment is worth it.

Laravel 11 will be released on February 6th, 2024. Its development is still ongoing. Let's dive into every relevant new feature we know about already.

Start leveraging the power of AI today. It enables developers to do incredible things, and many startups build products around it.

Powered by