Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Property Hooks Get Closer to Becoming a Reality in PHP 8.4

    Property Hooks Get Closer to Becoming a Reality in PHP 8.4

    April 19, 2024

    The Property Hooks RFC passed a significant milestone, getting an overwhelmingly positive 34 “yes” votes and only 1 “no” vote. That’s well above the required 2/3 majority required to pass.

    What are property hooks in PHP?

    Here’s the proposal summary from the RFC:

    Developers often use methods to wrap and guard access to object properties. There are several highly common patterns for such logic, which in practice may be verbose to implement repeatedly. Alternatively, developers may use __get and __set to intercept reads and writes generically, but that is a sledge-hammer approach that intercepts all undefined (and some defined) properties unconditionally. Property hooks provide a more targeted, purpose-built tool for common property interactions…

    This RFC introduces two “hooks” to override the default “get” and “set” behavior of a property. Although not included in this initial version, the design includes the ability to support more hooks in the future.

    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;
    }
    }
    }

    The syntax doesn’t require that both hooks always be defined together; in fact, here’s an example of only defining set from the RFC:

    class User
    {
    public string $name {
    set {
    if (strlen($value) === 0) {
    throw new ValueError(“Name must be non-empty”);
    }
    $this->name = $value;
    }
    }
     
    public function __construct(string $name) {
    $this->name = $name;
    }
    }

    You can read all the details about Property Hooks in PHP in the RFC. This feature looks likely to drop in PHP 8.4. The implementation is already a draft pull request if you want to see the discussion and progress of this feature.

    The post Property Hooks Get Closer to Becoming a Reality in PHP 8.4 appeared first on Laravel News.

    Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleAssemblyAI + 🔗LangChain Go, Universal-1 Recap
    Next Article Newsletter 32:⚡️Upgrades To Streaming Speech-to-Text

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 17, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-40906 – MongoDB BSON Serialization BSON::XS Multiple Vulnerabilities

    May 17, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    DeepSeek-AI Releases Janus-Pro 7B: An Open-Source multimodal AI that Beats DALL-E 3 and Stable Diffusion

    Machine Learning

    How Figma Migrated to Kubernetes in Under a Year: A Success Story

    Development

    Edge AI and It’s Advantages over Traditional AI

    Development

    French deeptech mirSense raises €7M to industrialise quantum laser tech

    News & Updates

    Highlights

    Designer Spotlight: Huy Phan

    March 21, 2025

    Award-winning designer Huy Phan shares his journey, creative philosophy, and the stories behind his most…

    CVE-2025-4189 – WordPress Audio Comments Plugin CSRF

    May 17, 2025

    Exploring creative possibilities: A visual guide to Amazon Nova Canvas

    March 16, 2025

    Artificial Intelligence for Reiki: Digital Tools and Practices

    February 24, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.