Source for file DibiObject.php
Documentation is available at DibiObject.php
- 1: <?php
- 3: /**
- 4: * dibi - tiny'n'smart database abstraction layer
- 5: * ----------------------------------------------
- 6: *
- 11: */
- 15: /**
- 16: * DibiObject is the ultimate ancestor of all instantiable classes.
- 17: *
- 18: * DibiObject is copy of Nette\Object from Nette Framework (http://nette.org).
- 19: *
- 20: * It defines some handful methods and enhances object core of PHP:
- 21: * - access to undeclared members throws exceptions
- 22: * - support for conventional properties with getters and setters
- 23: * - support for event raising functionality
- 24: * - ability to add new methods to class (extension methods)
- 25: *
- 26: * Properties is a syntactic sugar which allows access public getter and setter
- 27: * methods as normal object variables. A property is defined by a getter method
- 28: * and optional setter method (no setter method means read-only property).
- 29: * <code>
- 30: * $val = $obj->label; // equivalent to $val = $obj->getLabel();
- 31: * $obj->label = 'Nette'; // equivalent to $obj->setLabel('Nette');
- 32: * </code>
- 33: * Property names are case-sensitive, and they are written in the camelCaps
- 34: * or PascalCaps.
- 35: *
- 36: * Event functionality is provided by declaration of property named 'on{Something}'
- 37: * Multiple handlers are allowed.
- 38: * <code>
- 39: * public $onClick; // declaration in class
- 40: * $this->onClick[] = 'callback'; // attaching event handler
- 41: * if (!empty($this->onClick)) ... // are there any handlers?
- 42: * $this->onClick($sender, $arg); // raises the event with arguments
- 43: * </code>
- 44: *
- 45: * Adding method to class (i.e. to all instances) works similar to JavaScript
- 46: * prototype property. The syntax for adding a new method is:
- 47: * <code>
- 48: * MyClass::extensionMethod('newMethod', function(MyClass $obj, $arg, ...) { ... });
- 49: * $obj = new MyClass;
- 50: * $obj->newMethod($x);
- 51: * </code>
- 52: *
- 55: */
- 57: {
- 63: /**
- 64: * Returns the name of the class of this object.
- 66: */
- 68: {
- 70: }
- 74: /**
- 75: * Access to reflection.
- 77: */
- 79: {
- 81: }
- 85: /**
- 86: * Call to undefined method.
- 91: */
- 93: {
- 98: }
- 100: // event functionality
- 112: }
- 113: }
- 114: }
- 116: }
- 117: }
- 119: // extension methods
- 123: }
- 126: }
- 130: /**
- 131: * Call to undefined static method.
- 136: */
- 138: {
- 141: }
- 145: /**
- 146: * Adding method to class.
- 150: */
- 152: {
- 160: }
- 161: }
- 163: }
- 173: }
- 179: }
- 181: // works as getter
- 187: }
- 193: }
- 200: }
- 201: }
- 203: }
- 207: /**
- 208: * Returns property value. Do not call directly.
- 212: */
- 214: {
- 219: }
- 221: // property getter support
- 225: // ampersands:
- 226: // - uses &__get() because declaration should be forward compatible (e.g. with Nette\Web\Html)
- 227: // - doesn't call &$this->$m because user could bypass property setter by: $x = & $obj->property; $x = 'new value';
- 230: }
- 236: }
- 240: }
- 244: /**
- 245: * Sets value of a property. Do not call directly.
- 250: */
- 252: {
- 257: }
- 259: // property setter support
- 270: }
- 271: }
- 275: }
- 279: /**
- 280: * Is property defined?
- 283: */
- 285: {
- 288: }
- 292: /**
- 293: * Access to undeclared property.
- 297: */
- 299: {
- 302: }
- 306: /**
- 307: * Has property an accessor?
- 311: */
- 313: {
- 316: // get_class_methods returns private, protected and public methods of Object (doesn't matter)
- 317: // and ONLY PUBLIC methods of descendants (perfect!)
- 318: // but returns static methods too (nothing doing...)
- 319: // and is much faster than reflection
- 320: // (works good since 5.0.4)
- 322: }
- 324: }
- 326: }