ReturnTypeWillChange
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
ReturnTypeWillChange
Референца за `class.returntypewillchange.php` со подобрена типографија и навигација.
Атрибутот ReturnTypeWillChange
(PHP 8 >= 8.1.0)
Вовед
As of PHP 8.1.0, a tentative phase of transitioning to return type declarations for internal class methods began.
Most non-final internal methods now require overriding methods to declare a compatible return type. Otherwise, a deprecation notice is emitted during inheritance validation warning that the signature violates covariance rules.
In a future PHP version, method signature checking will become strict, and mismatches will cause a fatal error.
In case the return type cannot be declared for an overriding method due to PHP cross-version compatibility concerns, or the overriding method declares an incompatible return type, a #[\ReturnTypeWillChange] Ако типот на враќање не може да се декларира за надредена метода поради проблеми со компатибилноста на PHP верзиите, може да се додаде
When overriding methods defined in user-defined classes, return types are checked strictly. A fatal error is emitted on mismatch, even if the overriding method is marked with the attribute.
На ReturnTypeWillChange attribute suppresses deprecation warnings only during the tentative return type phase. After strict type checking is enforced, the attribute will stop working and a mismatch in the overriding method signature of an internal class will cause a fatal error.
Синопсис на класата
Види Исто така
Содржина
- ReturnTypeWillChange::__construct — Конструирај нова инстанца на атрибутот ReturnTypeWillChange