]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - vendor/wikimedia/remex-html/RemexHtml/PropGuard.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / vendor / wikimedia / remex-html / RemexHtml / PropGuard.php
diff --git a/vendor/wikimedia/remex-html/RemexHtml/PropGuard.php b/vendor/wikimedia/remex-html/RemexHtml/PropGuard.php
new file mode 100644 (file)
index 0000000..00c3c4d
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+namespace RemexHtml;
+
+/**
+ * This is a statically configurable mechanism for preventing the setting of
+ * undeclared properties on objects. The point of it is to detect programmer
+ * errors.
+ */
+class PropGuard {
+       public static $armed = true;
+
+       public static function set( $obj, $name, $value ) {
+               if ( self::$armed ) {
+                       throw new \Exception( "Property \"$name\" on object of class " . get_class( $obj ) .
+                               " is undeclared" );
+               } else {
+                       $obj->$name = $value;
+               }
+       }
+}