2021-02-26 16:16:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Safe;
|
|
|
|
|
|
|
|
use Safe\Exceptions\ClassobjException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an alias named alias
|
2022-07-12 19:26:21 +00:00
|
|
|
* based on the user defined class class.
|
2021-02-26 16:16:17 +00:00
|
|
|
* The aliased class is exactly the same as the original class.
|
|
|
|
*
|
2022-07-12 19:26:21 +00:00
|
|
|
* @param string $class The original class.
|
2021-02-26 16:16:17 +00:00
|
|
|
* @param string $alias The alias name for the class.
|
|
|
|
* @param bool $autoload Whether to autoload if the original class is not found.
|
|
|
|
* @throws ClassobjException
|
|
|
|
*
|
|
|
|
*/
|
2022-07-12 19:26:21 +00:00
|
|
|
function class_alias(string $class, string $alias, bool $autoload = true): void
|
2021-02-26 16:16:17 +00:00
|
|
|
{
|
|
|
|
error_clear_last();
|
2022-07-12 19:26:21 +00:00
|
|
|
$result = \class_alias($class, $alias, $autoload);
|
2021-02-26 16:16:17 +00:00
|
|
|
if ($result === false) {
|
|
|
|
throw ClassobjException::createFromPhpError();
|
|
|
|
}
|
|
|
|
}
|