Statement on glibc/iconv Vulnerability

AllowDynamicProperties クラス

(PHP 8 >= 8.2.0)

はじめに

このアトリビュートを使うと、 クラスに 動的なプロパティ を許可することをマークできます。

クラス概要

final class AllowDynamicProperties {
/* メソッド */
public __construct()
}

動的なプロパティは、PHP 8.2.0 以降は推奨されなくなりました。 よって、このアトリビュートでクラスをマークせずに、 動的なプロパティを使うと、 推奨されない警告が発生します。

<?php
class DefaultBehaviour { }

#[
\AllowDynamicProperties]
class
ClassAllowsDynamicProperties { }

$o1 = new DefaultBehaviour();
$o2 = new ClassAllowsDynamicProperties();

$o1->nonExistingProp = true;
$o2->nonExistingProp = true;
?>

上の例の PHP 8.2 での出力は、このようになります。:

Deprecated: Creation of dynamic property DefaultBehaviour::$nonExistingProp is deprecated in file on line 10

目次

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top