From 7eee27854f4f4c182a052b1bc03f2cf8ea315ad6 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 21 Dec 2023 15:40:39 +1300 Subject: [PATCH] Bubble up deprecation if getVar used to get a deprecated property --- CRM/Core/Form.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 6cab90d985..6a95c15067 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -18,6 +18,8 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ +use Civi\Api4\Utils\ReflectionUtils; + require_once 'HTML/QuickForm/Page.php'; /** @@ -2095,6 +2097,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @return mixed */ public function getVar($name) { + if (!empty(ReflectionUtils::getCodeDocs((new ReflectionProperty($this, $name)), 'Property')['deprecated'])) { + CRM_Core_Error::deprecatedWarning('deprecated property accessed :' . $name); + } + // @todo - add warnings for internal properties & protected properties. return $this->$name; } -- 2.25.1