Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
      • Traits
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

Classes

  • Configurator
  • Framework
  • LegacyObject

Traits

  • SmartObject
  • StaticClass

Exceptions

  • ArgumentOutOfRangeException
  • DeprecatedException
  • DirectoryNotFoundException
  • FileNotFoundException
  • InvalidArgumentException
  • InvalidStateException
  • IOException
  • MemberAccessException
  • NotImplementedException
  • NotSupportedException
  • OutOfRangeException
  • StaticClassException
  • UnexpectedValueException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases

Class LegacyObject

Nette\Object is the ultimate ancestor of all instantiable classes.

It defines some handful methods and enhances object core of PHP: - access to undeclared members throws exceptions - support for conventional properties with getters and setters - support for event raising functionality - ability to add new methods to class (extension methods)

Properties is a syntactic sugar which allows access public getter and setter methods as normal object variables. A property is defined by a getter method or setter method (no setter method means read-only property).

$val = $obj->label;     // equivalent to $val = $obj->getLabel();
$obj->label = 'Nette';  // equivalent to $obj->setLabel('Nette');

Property names are case-sensitive, and they are written in the camelCaps or PascalCaps.

Event functionality is provided by declaration of property named 'on{Something}' Multiple handlers are allowed.

public $onClick;                // declaration in class
$this->onClick[] = 'callback';  // attaching event handler
if (!empty($this->onClick)) ... // are there any handlers?
$this->onClick($sender, $arg);  // raises the event with arguments

Adding method to class (i.e. to all instances) works similar to JavaScript prototype property. The syntax for adding a new method is:

MyClass::extensionMethod('newMethod', function (MyClass $obj, $arg, ...) { ... });
$obj = new MyClass;
$obj->newMethod($x);
Abstract
Namespace: Nette
Deprecated: use trait Nette\SmartObject
Located at Utils/LegacyObject.php
Methods summary
public static Nette\Reflection\ClassType|ReflectionClass
# getReflection( )

Access to reflection.

Access to reflection.

Returns

Nette\Reflection\ClassType|ReflectionClass
Nette\Reflection\ClassType|\ReflectionClass
public mixed
# __call( string $name, array $args )

Call to undefined method.

Call to undefined method.

Parameters

$name
name
$args
arguments

Returns

mixed
mixed

Throws

Nette\MemberAccessException
MemberAccessException
public static mixed
# __callStatic( string $name, array $args )

Call to undefined static method.

Call to undefined static method.

Parameters

$name
name (in lower case!)
$args
arguments

Returns

mixed
mixed

Throws

Nette\MemberAccessException
MemberAccessException
public static mixed
# extensionMethod( string $name, callable $callback = null )

Adding method to class.

Adding method to class.

Parameters

$name
name
$callback

Returns

mixed
mixed
public mixed &
# __get( string $name )

Returns property value. Do not call directly.

Returns property value. Do not call directly.

Parameters

$name
name

Returns

mixed
property value

Throws

Nette\MemberAccessException
if the property is not defined.
public
# __set( string $name, mixed $value )

Sets value of a property. Do not call directly.

Sets value of a property. Do not call directly.

Parameters

$name
name
$value
value

Throws

Nette\MemberAccessException
if the property is not defined or is read-only
public boolean
# __isset( string $name )

Is property defined?

Is property defined?

Parameters

$name
name

Returns

boolean
bool
public
# __unset( string $name )

Access to undeclared property.

Access to undeclared property.

Parameters

$name
name

Throws

Nette\MemberAccessException
MemberAccessException
Magic properties summary
public read-only Nette\Reflection\ClassType|ReflectionClass $reflection
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0