Source for file ObjectMixin.php
Documentation is available at ObjectMixin.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- 7: *
- 8: * This source file is subject to the "Nette license" that is bundled
- 9: * with this package in the file license.txt.
- 10: *
- 11: * For more information please see https://nette.org
- 12: *
- 19: */
- 29: /**
- 30: * Nette\Object behaviour mixin.
- 31: *
- 35: */
- 37: {
- 46: /**
- 47: * Static class - cannot be instantiated.
- 48: */
- 50: {
- 52: }
- 56: /**
- 57: * Call to undefined method.
- 58: *
- 63: */
- 65: {
- 70: }
- 72: // event functionality
- 82: throw new InvalidStateException("Event handler '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
- 83: }
- 85: }
- 86: }
- 88: }
- 89: }
- 91: // extension methods
- 95: }
- 98: }
- 102: /**
- 103: * Adding method to class.
- 104: *
- 109: */
- 111: {
- 119: }
- 120: }
- 122: }
- 131: throw new InvalidArgumentException("Extension method handler '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
- 132: }
- 136: }
- 138: // works as getter
- 144: }
- 151: }
- 158: }
- 159: }
- 161: }
- 165: /**
- 166: * Returns property value.
- 167: *
- 171: */
- 173: {
- 178: }
- 181: // get_class_methods returns ONLY PUBLIC methods of objects
- 182: // but returns static methods too (nothing doing...)
- 183: // and is much faster than reflection
- 184: // (works good since 5.0.4)
- 186: }
- 188: // property getter support
- 192: // ampersands:
- 193: // - uses &__get() because declaration should be forward compatible (e.g. with Nette\Web\Html)
- 194: // - doesn't call &$_this->$m because user could bypass property setter by: $x = & $obj->property; $x = 'new value';
- 197: }
- 203: }
- 207: }
- 211: /**
- 212: * Sets value of a property.
- 213: *
- 218: */
- 220: {
- 225: }
- 229: }
- 231: // property setter support
- 233: if (isset(self::$methods[$class]['get' . $name]) || isset(self::$methods[$class]['is' . $name])) {
- 242: }
- 243: }
- 247: }
- 251: /**
- 252: * Is property defined?
- 253: *
- 256: */
- 258: {
- 261: }
- 266: }
- 269: return isset(self::$methods[$class]['get' . $name]) || isset(self::$methods[$class]['is' . $name]);
- 270: }
- 272: }
