1<?php
2
3namespace RemexHtml;
4
5/**
6 * This is a statically configurable mechanism for preventing the setting of
7 * undeclared properties on objects. The point of it is to detect programmer
8 * errors.
9 */
10trait PropGuard {
11	public static $armed = true;
12
13	public function __set( $name, $value ) {
14		if ( self::$armed ) {
15			throw new \Exception( "Property \"$name\" on object of class " . get_class( $this ) .
16				" is undeclared" );
17		} else {
18			$this->$name = $value;
19		}
20	}
21}
22