タグ

ブックマーク / php.watch (1)

  • PHP 8.2: Dynamic Properties are deprecated

    In PHP classes, it is possible to dynamically set and retrieve class properties that are not declared. These properties do not adhere to a specific (similar to typed properties), and it requires the use of __get() and __set() magic methods to effectively prevent or control how dynamic properties are set and retrieved. class User { private int $uid; } $user = new User(); $user->name = 'Foo'; In the

    efcl
    efcl 2023/09/17
    PHP 8.2で宣言されてないクラスのプロパティを読み書きするのがDeprecatedとなり、9.0で削除される。 `__get`/`__set`、`#[AllowDynamicProperties]`かWeakMapでの紐付けが代替手段
  • 1