Backend Development 5 min read

New Features in PHP 8.4.1: Property Hooks, Asymmetric Visibility, Deprecation Attributes, Ext‑DOM Enhancements, BCMath Object API, and New array_* Functions

PHP 8.4.1 introduces a suite of backend improvements—including property hooks, asymmetric visibility, deprecation attributes, a spec‑compliant DOM API, an object‑oriented BCMath API, and several new array_* functions—each illustrated with concise code examples and usage notes.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
New Features in PHP 8.4.1: Property Hooks, Asymmetric Visibility, Deprecation Attributes, Ext‑DOM Enhancements, BCMath Object API, and New array_* Functions

The PHP development team released PHP 8.4.1 on November 21, bringing a collection of security fixes and major language enhancements that target backend developers.

1. Property Hooks allow computed properties to be understood directly by IDEs and static analysis tools, eliminating the need for fragile docblock annotations. They enable reliable pre‑ and post‑processing of values without explicit getters or setters.

countryCode = strtoupper($countryCode);
        }
    }
    public string $combinedCode {
        get => sprintf("%s_%s", $this->languageCode, $this->countryCode);
        set(string $value) {
            [$this->languageCode, $this->countryCode] = explode('_', $value, 2);
        }
    }
    public function __construct(string $languageCode, string $countryCode) {
        $this->languageCode = $languageCode;
        $this->countryCode = $countryCode;
    }
}
$brazilianPortuguese = new Locale('pt', 'br');
var_dump($brazilianPortuguese->countryCode); // BR
var_dump($brazilianPortuguese->combinedCode); // pt_BR
?>

2. Asymmetric Visibility lets developers control the write‑access scope of a property separately from its read‑access scope, reducing the need for verbose getter methods that expose values without permitting external modification.

3. Deprecation Attributes extend PHP’s deprecation mechanism to user‑defined functions, methods, and class constants, providing clearer migration paths.

getVersion();
    }
    public function getVersion(): string { return '8.4'; }
}
$phpVersion = new PhpVersion();
// Deprecated: Method PhpVersion::getPhpVersion() is deprecated since 8.4, use PhpVersion::getVersion() instead
echo $phpVersion->getPhpVersion();
?>

4. New ext‑dom Features and HTML5 Support add a standards‑compliant DOM API, fixing long‑standing spec bugs and providing classes such as Dom\HTMLDocument and Dom\XMLDocument for easier document handling.

PHP 8.4 is a feature‑rich release!
PHP 8.4 adds new DOM classes that are spec‑compliant, keeping the old ones for compatibility.
HTML,
    LIBXML_NOERROR
);
$node = $dom->querySelector('main > article:last-child');
var_dump($node->classList->contains('featured')); // bool(true)
?>

5. BCMath Object API introduces BcMath\Number , an immutable, stringable object that enables object‑oriented arbitrary‑precision arithmetic.

$num2); // false
?>

6. New array_*() Functions add array_find() , array_find_key() , array_any() , and array_all() to simplify common array operations.

str_starts_with($value, 'c')
);
var_dump($animal); // string(3) "cat"
?>

For a complete list of changes, refer to the official release notes at https://www.php.net/releases/8.4/zh.php .

backendPHPnew-featuresdeprecationarray-functionsAsymmetric Visibilitybcmathdom-apiPHP 8.4Property Hooks
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.