Statement on glibc/iconv Vulnerability

废弃的功能

PHP 核心

动态属性的使用

弃用动态属性创建,除非类选择使用 #[\AllowDynamicProperties] 注解。stdClass 允许动态属性。__get()/__set() 魔术方法不受此更改的影响。解决动态属性弃用警告,可以通过以下方式:

  • 声明属性(首选)。
  • #[\AllowDynamicProperties] 添加到 #[\AllowDynamicProperties](这也适用于所有子类)。
  • 如果需要将附加数据于不属于自己的对象相关联,则使用 WeakMap

Relative callables

弃用 $callable() 语法不接受的可调用对象(但 call_user_func() 接受)。尤其是:

  • "self::method"
  • "parent::method"
  • "static::method"
  • ["self", "method"]
  • ["parent", "method"]
  • ["static", "method"]
  • ["Foo", "Bar::method"]
  • [new Foo, "Bar::method"]
这不会影响正常方法调用,比如 "A::method"["A", "method"]

"${var}""${expr}" 样式插值

弃用字符串插值的 "${var}""${expr}" 样式。 Use "$var"/"{$var}" and "{${expr}}", respectively.

MBString

对于所有的 MBString 函数,已经弃用了 QPrintBase64UuencodeHTML-ENTITIES 等“文本编码”。 与 MBString 支持的其他文本编码不同,这些编码不是对 Unicode 码点序列进行编码,而是对原始字节序列进行编码。当指定了这些非编码时,大多数 MBString 函数的返回值不清楚是否正确。此外,PHP 已经内置了它们的单独实现;例如,可以使用 convert_uuencode()/convert_uudecode() 处理 Uuencode 编码的数据。

SPL

弃用内部方法 SplFileInfo::_bad_state_ex()

标准

弃用 utf8_encode()utf8_decode()

add a note

User Contributed Notes 1 note

up
-12
tabflo at gmx dot at
9 months ago
a have a baseclass for all databasemodels and handle my dynamic property setter and getter this way:

    public array $dynamicProperties = [];

    public function __set(string $name, mixed $value) {
        if(property_exists($this, $name))
            $this->{$name} = $value;
        else
            $this->dynamicProperties[$name] = $value;
    }
   
    public function __get(string $name) {
        if(property_exists($this, $name))
            return $this->$name;
        else
            return $this->dynamicProperties[$name];
    }

just put the content into a class and extend from it. enjoy :)
To Top