Add the Request and Response objects copied from phalanx
[hoplite.git] / base / strict_object.php
1 <?php
2 // Hoplite
3 // Copyright (c) 2011 Blue Static
4 //
5 // This program is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 // more details.
13 //
14 // You should have received a copy of the GNU General Public License along with
15 // this program. If not, see <http://www.gnu.org/licenses/>.
16
17 namespace hoplite\base;
18
19 /*!
20 Objects that expose public properties without accessors |public $foo = NULL;|
21 should inherit from this class to prevent undefined property access. This
22 prevents subtle bugs caused by typos. For arbitrary key-value storage, use a
23 Dictionary.
24 */
25 class StrictObject
26 {
27 public function __get($key)
28 {
29 throw new StrictObjectException('Cannot get ' . get_class($this) . '::' . $key);
30 }
31
32 public function __set($key, $value)
33 {
34 throw new StrictObjectException('Cannot set ' . get_class($this) . '::' . $key);
35 }
36 }
37
38 class StrictObjectException extends \Exception {}