1.2.1086. Set class_alias() Definition

Links identifiers and nsname to the concrete class, interface, trait and enumeration when class_alias() was used to create the name. The link is DEFINITION.

class_alias() are detected at loading time, and are used unconditionally.

This means that the fully qualified name of the new call and the instantiated class may be different : without the alias, the fully qualified name is the current value, or its use’s origin, while with class_alias(), it is an arbitrary name.

<?php

class x {
    public function foo() {}
}

class_alias('x', 'y');

//y exists, as an alias of x.
$y = new y;

?>

1.2.1086.1. Specs

Short name

Complete/SetClassAliasDefinition

Rulesets

All, NoDoc

Exakat since

1.9.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

class-alias

Available in

Entreprise Edition, Exakat Cloud