Classes and Objects
A class in iXML is an array prototype. It defines properties, a constructor, and methods. An object is an instance of a class, created with <new>.
class — Class definition
Syntax
XML
<class var="MyClass">
<extends class="ParentClass"/>
<property name="propName">default value</property>
<constructor>
<set var="this.propName">$paramValue</set>
</constructor>
<method name="methodName">
<set var="return">$this.propName</set>
</method>
</class>
Constituents
- Properties: Default key-value pairs.
- Constructor: Automatic initialization routine.
- Methods: Functions bound to the instance check.
new — New instance
Creates a new object from a class.
Syntax
XML
<new class="ClassName" var="objectVar">
<param name="paramName">value</param>
</new>
method — Method definition
Full reference →
Defines a function bound to the class. Inside a method, $this refers to the object instance.
Inheritance
Classes can inherit from parent classes using <extends>.
- The child inherits all properties and methods.
- Constructors execute in chain order: Parent first, then Child.
- Methods can be overridden by redefining them in the child.
Introspection
instanceof: Check if an object is an instance of a class.classinfo: Retrieve structural information about a class.