CodeLoops Logo
  • HOME
  • ABOUT
  • SERVICES
  • PROJECTS
  • BLOG
  • CONTACT US
Codeloops - A Look at What's Coming to PHP 8.4

A Look at What's Coming to PHP 8.4

  1. Home
  2. Blog
  3. Post

A Look at What's Coming to PHP 8.4

Sunday May 19, 2024

PHP 8.4 is coming soon and in this post let's look at what has been announced so far, and what new features you might expect.

When is PHP 8.4 scheduled to be released?

PHP 8.4 is scheduled to be released on November 21, 2024. Before the release it will feature 6 months of pre-release phases going from Alphas, to Betas, to Release Candidates, and then the official release.

PHP Property Hooks

Property hooks are inspired by languages like Kotlin, C#, and Swift, and the syntax includes two syntax variants that resemble short and multi-line closures:

class User implements Named
{
    private bool $isModified = false;
 
    public function __construct(
        private string $first,
        private string $last
    ) {}
 
    public string $fullName {
        // Override the "read" action with arbitrary logic.
        get => $this->first . " " . $this->last;
 
        // Override the "write" action with arbitrary logic.
        set {
            [$this->first, $this->last] = explode(' ', $value, 2);
            $this->isModified = true;
        }
    }
}

Property hooks will help remove boilerplate of property getters and setters, allowing a property to define access and updates using hooks.

Check out our post for more details: Property Hooks in PHP 8.4.

new MyClass()->method() without parentheses

Since member access during instantiation was introduced, you must wrap the new MyClass() call in parentheses, or you'll get a parse error. The proposed syntax would allow you to access constants, properties, and methods without the extra parentheses:

// Wrapping parentheses are required to access class members
$request = (new Request())->withMethod('GET')->withUri('/hello-world');
 
// PHP Parse error (<= PHP 8.3): syntax error, unexpected token "->"
$request = new Request()->withMethod('GET')->withUri('/hello-world');

This update fixes papercut that makes working with class member access simpler, not having to add surrounding parentheses or using a static constructor method. This syntax change also puts PHP more in alignment with other C languages like Java, C#, and TypeScript, which don't require surrounded parentheses.

Check out our post for more details: Class Instantiation Without Extra Parenthesis in PHP 8.4.

Learn More

You can follow the PHP 8.4 Preparation Tasks on the wiki.

  • Posted on May 19, 2024
  • Click for Source
CodeLoops Logo

Authentic and innovative.
Built to the smallest detail
with a focus on usability
and performance.

Get in Touch

  • +961-1-880553
  • +961-3-054401
  • [email protected]
  • Qubic Business Center, Office 8A, Sin el Fil

Our Services

  • Website Development
  • Mobile Applications
  • E-Commerce Solutions
  • All Services

Copyrights © 2025 Codeloops OÜ. All Rights Reserved.

Powered by Codeloops OÜ.

Menu
Search

What are you looking for?

Search for tutorials, news and latest trends.