code: protected function registerBundle($bundles, $name, &$registered)
      {
          if (!isset($registered[$name])) {
              $registered[$name] = false;
              $bundle = $bundles[$name];
              foreach ($bundle->depends as $depend) {
                  $this->registerBundle($bundles, $depend, $registered);
              }
              unset($registered[$name]);
              $registered[$name] = $bundle;
          } elseif ($registered[$name] === false) {
              throw new Exception("A circular dependency is detected for target '{$name}': " . $this->composeCircularDependencyTrace($name, $registered) . '.');
          }
      }
docs: Registers asset bundles including their dependencies.
  @param \yii\web\AssetBundle[] $bundles asset bundles list.
  @param string $name bundle name.
  @param array $registered stores already registered names.
  @throws Exception if circular dependency is detected.