PHP 8.3 语法变化 - 某些 PHP 扩展类中的类常量类型声明

作者: 温新

图书: 【PHP 8.3 新特性】

阅读: 522

时间: 2024-11-19 23:28:07

hi,我是温新,一名 PHPer

作为对 PHP 8.3 中支持类常量类型的后续更改,Phar、SNMP 和 Phar 扩展类常量已更新为常量类型。

任何扩展以下类的用户级 PHP 类并覆盖现有常量的类都将导致致命错误。

用户级PHP类通常不会扩展这些类并覆盖常量。

受影响的扩展

  • \Phar 类来自 Phar 扩展
  • \SNM P类来自 SNMP 扩展
  • \ZipArchive 类来自 Zip 扩展

Phar 扩展类常量类型

Phar 扩展声明了一个 Phar 类,该类声明了几个类常量。在 PHP 8.3 中,Phar 类常量使用类型声明。

 class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess {
     const int BZ2 = UNKNOWN;
     const int GZ = UNKNOWN;
     const int NONE = UNKNOWN;
     const int PHAR = UNKNOWN;
     const int TAR = UNKNOWN;
     const int ZIP = UNKNOWN;
     const int COMPRESSED = UNKNOWN;
     const int PHP = UNKNOWN;
     const int PHPS = UNKNOWN;
     const int MD5 = UNKNOWN;
     const int OPENSSL = UNKNOWN;
     const int OPENSSL_SHA256 = UNKNOWN;
     const int OPENSSL_SHA512 = UNKNOWN;
     const int SHA1 = UNKNOWN;
     const int SHA256 = UNKNOWN;
     const int SHA512 = UNKNOWN;
 }

SNMP 扩展类常量类型

class SNMP {
    public const int VERSION_1 = UNKNOWN;
    public const int VERSION_2c = UNKNOWN;
    public const int VERSION_2C = UNKNOWN;
    public const int VERSION_3 = UNKNOWN;
    public const int ERRNO_NOERROR = UNKNOWN;
    public const int ERRNO_ANY = UNKNOWN;
    public const int ERRNO_GENERIC = UNKNOWN;
    public const int ERRNO_TIMEOUT = UNKNOWN;
    public const int ERRNO_ERROR_IN_REPLY = UNKNOWN;
    public const int ERRNO_OID_NOT_INCREASING = UNKNOWN;
    public const int ERRNO_MULTIPLE_SET_QUERIES = UNKNOWN;
}
请登录后再评论