Source for file Object.php
Documentation is available at Object.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 11: */
- 15: /**
- 16: * Nette\Object is the ultimate ancestor of all instantiable classes.
- 17: *
- 18: * It defines some handful methods and enhances object core of PHP:
- 19: * - access to undeclared members throws exceptions
- 20: * - support for conventional properties with getters and setters
- 21: * - support for event raising functionality
- 22: * - ability to add new methods to class (extension methods)
- 23: *
- 24: * Properties is a syntactic sugar which allows access public getter and setter
- 25: * methods as normal object variables. A property is defined by a getter method
- 26: * and optional setter method (no setter method means read-only property).
- 27: * <code>
- 28: * $val = $obj->label; // equivalent to $val = $obj->getLabel();
- 29: * $obj->label = 'Nette'; // equivalent to $obj->setLabel('Nette');
- 30: * </code>
- 31: * Property names are case-sensitive, and they are written in the camelCaps
- 32: * or PascalCaps.
- 33: *
- 34: * Event functionality is provided by declaration of property named 'on{Something}'
- 35: * Multiple handlers are allowed.
- 36: * <code>
- 37: * public $onClick; // declaration in class
- 38: * $this->onClick[] = 'callback'; // attaching event handler
- 39: * if (!empty($this->onClick)) ... // are there any handlers?
- 40: * $this->onClick($sender, $arg); // raises the event with arguments
- 41: * </code>
- 42: *
- 43: * Adding method to class (i.e. to all instances) works similar to JavaScript
- 44: * prototype property. The syntax for adding a new method is:
- 45: * <code>
- 46: * MyClass::extensionMethod('newMethod', function(MyClass $obj, $arg, ...) { ... });
- 47: * $obj = new MyClass;
- 48: * $obj->newMethod($x);
- 49: * </code>
- 50: *
- 53: *
- 56: */
- 58: {
- 60: /**
- 62: */
- 64: {
- 65: trigger_error(__METHOD__ . '() is deprecated; use getReflection()->getName() instead.', E_USER_WARNING);
- 67: }
- 71: /**
- 72: * Access to reflection.
- 73: *
- 75: */
- 77: {
- 79: }
- 83: /**
- 84: * Call to undefined method.
- 85: *
- 90: */
- 92: {
- 94: }
- 98: /**
- 99: * Call to undefined static method.
- 100: *
- 105: */
- 107: {
- 110: }
- 114: /**
- 115: * Adding method to class.
- 116: *
- 120: */
- 122: {
- 127: }
- 133: }
- 134: }
- 138: /**
- 139: * Returns property value. Do not call directly.
- 140: *
- 144: */
- 146: {
- 148: }
- 152: /**
- 153: * Sets value of a property. Do not call directly.
- 154: *
- 159: */
- 161: {
- 163: }
- 167: /**
- 168: * Is property defined?
- 169: *
- 172: */
- 174: {
- 176: }
- 180: /**
- 181: * Access to undeclared property.
- 182: *
- 186: */
- 188: {
- 189: throw new MemberAccessException("Cannot unset the property {$this->reflection->name}::\$$name.");
- 190: }
- 192: }