You are viewing documentation for an outdated version. It is no longer supported!

Property overloading

Each defined property is accessible in multiple ways, if a getter and or setter method has been defined for that given property.

For additional information, please read about Mutators and Accessoropen in new window, PHP's overloadingopen in new window, and PHP's Array-Accessopen in new window

// Create a new instance of your DTO
$person = new Person();

// Name can be set using normal setter methods
$person->setName('John');

// But you can also just set the property itself
$person->name = 'Jack'; // Will automatically invoke setName()

// And you can also set it, using an array-accessor
$person['name'] = 'Jane'; // Will also automatically invoke setName()

// ... //

// Obtain age using the regular getter method
$age = $person->getAge();

// Can also get it via invoking the property directly
$age = $person->age; // Will automatically invoke getAge()

// Lastly, it can also be access via an array-accessor
$age = $person['age']; // Also invokes the getAge()

TIP

If you are using a modern IDEopen in new window, then it will most likely support PHPDocopen in new window.

By adding a @propertyopen in new window tag to your interface or concrete implementation, your IDE will be able to auto-complete the overloadable properties.

Behind the Scene

The Overload component is responsible for handling the properties overloading of the Dto abstraction.