NAME

@super - Call a method from a parent class

SYNOPSIS

@super.methodName [args...]

DESCRIPTION

The @super keyword can be used to call a parent class’s version of an overridden method from within a child class. This is used when extending parent method functionality while preserving the original behavior.

Key behaviors:

EXAMPLE

@class Parent {
	@virtual @public @method greet {
		echo "Hello from Parent"
    }
}

@class Child : Parent {
	@public @method greet {
		@super.greet  # Calls Parent.greet
		echo "Hello from Child"
    }
}

NOTES

Since @super merely changes the context to the parent class, it can be used in any context where @this would be used. This includes method calls, property accesses, etc.

Calling @super.toPrimitive or dereferencing via *@super will result in the parent class’s toPrimitive method being called.

Using @super only accesses the immediate parent class. It cannot traverse further up the class hierarchy.

SEE ALSO