MOON
Server: Apache
System: Linux res.emeff.ca 3.10.0-962.3.2.lve1.5.24.10.el7.x86_64 #1 SMP Wed Mar 20 07:36:02 EDT 2019 x86_64
User: accemeff (1004)
PHP: 7.0.33
Disabled: NONE
Upload Files
File: /home/accemeff/vendor/craftcms/cms/src/Yii.php
<?php
/**
 * @link https://craftcms.com/
 * @copyright Copyright (c) Pixel & Tonic, Inc.
 * @license https://craftcms.github.io/license/
 */

use craft\helpers\FileHelper;
use yii\BaseYii;
use yii\di\Container;

/**
 * @inheritdoc
 */
class Yii extends BaseYii
{
    /**
     * @var string[] Record of all registered aliases and the paths they map to.
     */
    private static $_aliasPaths = [];

    /**
     * @var bool Whether [[$aliasPaths]] has changed since it was last sorted.
     */
    private static $_aliasesChanged = false;

    /**
     * @inheritdoc
     */
    public static function setAlias($alias, $path)
    {
        parent::setAlias($alias, $path);
        self::$_aliasPaths[$alias] = FileHelper::normalizePath($path);
        self::$_aliasesChanged = true;
    }

    /**
     * Swaps the beginning of a path with the most specific alias we can find, if any.
     *
     * @param string $path
     * @return string
     */
    public static function alias(string $path): string
    {
        // Do the alias paths need to be sorted?
        if (self::$_aliasesChanged) {
            $lengths = [];
            foreach (self::$_aliasPaths as $aliasPath) {
                $lengths[] = strlen($aliasPath);
            }
            array_multisort($lengths, SORT_DESC, SORT_NUMERIC, self::$_aliasPaths);
            self::$_aliasesChanged = false;
        }

        $path = FileHelper::normalizePath($path);
        foreach (self::$_aliasPaths as $alias => $aliasPath) {
            if (strpos($path . '/', $aliasPath . '/') === 0) {
                return $alias . substr($path, strlen($aliasPath));
            }
        }
        return $path;
    }
}

Yii::$container = new Container();