Programatically change the base theme of the current theme I have a theme that is a child theme of 'stable'.

Currently the base theme is defined in the info.yml file, however i don't want its parent theme to be so permanent. 

I am looking for a way to be able to programatically change the base theme in code so that the theme could switch its parent on demand.
So as it turns out an info.yml file can be altered inside HOOK_system_info_alter

To change the base theme definition of an existing theme you can use the following 

function HOOK_system_info_alter(&amp;$info, $file, $type) {
  if ($type == 'theme') {
    if ($info['name'] == 'YOUR THEME NAME') {
      $info['base theme'] = 'NEW_BASE_THEME_NAME';
    }
  }
}


As this hook is only fired when caches are flushed there is no need for a separate cache flush after the change is made.