Bubble up deprecation if getVar used to get a deprecated property
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 21 Dec 2023 02:40:39 +0000 (15:40 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 21 Dec 2023 02:40:39 +0000 (15:40 +1300)
CRM/Core/Form.php

index 6cab90d98504a9e9e40c52781b4308fcb0985ec0..6a95c15067333224bc322e5b8018917fc51093ac 100644 (file)
@@ -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;
   }