PHP 8.4 New Features Overview
PHP 8.4, released on November 19 with a rapid 8.4.1 patch, introduces property hooks, parentheses‑free method chains, asymmetric visibility, new array_* functions, and HTML5‑aware DOM parsing, while the article also discusses PHP’s declining market share, community‑driven modernization, and advice for developers to stay competitive.
PHP 8.4 was released ahead of schedule on November 19, followed by a quick 8.4.1 patch on November 20, marking a faster release cadence than previous major versions.
1.1 Property Hooks – Property hooks introduce computed properties that IDEs and static analysis tools can understand without docblock annotations. They allow reliable pre‑processing or post‑processing of values without needing explicit getters or setters.
class BookViewModel { public function __construct( private array $authors, ) {} public string $credits { get { return implode(', ', array_map( fn (Author $author) => $author->name, $this->authors, )); } } public Author $mainAuthor { set (Author $mainAuthor) { $this->authors[] = $mainAuthor; $this->mainAuthor = $mainAuthor; } get => $this->mainAuthor; } }
1.2 Without Parentheses (Parentheses‑Free Method Chains) – Method chains can now omit unnecessary parentheses, simplifying the syntax.
Before (with parentheses):
$name = (new ReflectionClass($objectOrClass))->getShortName();
After (without parentheses):
$name = new ReflectionClass($objectOrClass)->getShortName();
1.3 Asymmetric Visibility – Write and read visibility can be controlled independently, reducing the need for verbose getter methods.
class ReadOnlyProperty { public string $data get; private string $data set; }
1.4 New array_*() Functions – PHP 8.4 adds array_find() , array_find_key() , array_any() and array_all() for more expressive array handling.
$numbers = [1, 2, 3, 4]; $found = array_find($numbers, fn($n) => $n > 2); echo $found; // output: 3
1.5 New HTML5 Support – The \DOMDocument class can now correctly parse HTML5 markup while retaining backward compatibility with the previous implementation.
$doc = \Dom\HTMLDocument::createFromString($contents);
2. PHP’s Future Outlook – PHP, created in 1995, grew from a simple HTTP‑form processor to a core component of the LAMP stack, powering roughly 78% of websites. However, its popularity has declined (TIOBE rank 17, Stack Overflow usage down to 18%). Competing languages such as Java, Python, Go, Rust, and Node.js offer type safety, performance, and modern concurrency models, leading many large‑scale systems to favor them.
2.1 Community‑Driven Transformation – Similar to Java’s cloud‑native initiatives (Project Leyden, Valhalla, Loom, Portola), the PHP community is modernizing the language with features that improve developer ergonomics and performance.
2.2 Is PHP Still Worth Learning?
Simple syntax without complex type handling or pointers.
Extensive standard library covering a wide range of functionalities.
Powerful string handling and templating capabilities.
Mature frameworks like Laravel and Symfony, and coroutine extensions such as Swoole.
Developers are encouraged to broaden their skill set: adopt AI assistants (ChatGPT, GitHub Copilot), use Docker for containerization, learn modern front‑end stacks (Vue, React), and explore other languages (C++, Go, Java) to stay competitive.
Tencent Cloud Developer
Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.