'Create the buffer-independent list of libs.'

def _buf_indep_libs_from_env(self, env):

    cache_key = 'php-libs'
    if (cache_key not in env.cache):
        env.add_pref_observer('php', self._invalidate_cache)
        env.add_pref_observer('codeintel_scan_extra_dir', self._invalidate_cache_and_rescan_extra_dirs)
        env.add_pref_observer('phpConfigFile', self._invalidate_cache)
        env.add_pref_observer('codeintel_selected_catalogs', self._invalidate_cache)
        env.add_pref_observer('codeintel_max_recursive_dir_depth', self._invalidate_cache)
        env.add_pref_observer('codeintel_scan_files_in_project', self._invalidate_cache)
        env.add_pref_observer('import_live', self._invalidate_cache_and_rescan_extra_dirs)
        env.add_pref_observer('import_dirname', self._invalidate_cache_and_rescan_extra_dirs)
        db = self.mgr.db
        php = None
        if env.has_pref('php'):
            php = (env.get_pref('php').strip() or None)
        if ((not php) or (not exists(php))):
            php = self._php_from_env(env)
        if (not php):
            log.warn('no    PHP    was    found    from    which    to    determine    the    import    path')
            (php_ver, include_path) = (None, [])
        else:
            (php_ver, include_path) = self._php_info_from_php(php, env)
        libs = []
        extra_dirs = self._extra_dirs_from_env(env)
        if extra_dirs:
            libs.append(db.get_lang_lib('PHP', 'extradirslib', extra_dirs, 'PHP'))
        include_dirs = [d for d in include_path if (d != '.') if exists(d)]
        if include_dirs:
            max_depth = env.get_pref('codeintel_max_recursive_dir_depth', 10)
            php_assocs = env.assoc_patterns_from_lang('PHP')
            include_dirs = tuple(util.gen_dirs_under_dirs(include_dirs, max_depth=max_depth, interesting_file_patterns=php_assocs))
            exclude_patterns = env.get_pref('codeintel_scan_exclude_dir')
            if (not (exclude_patterns is None)):
                for p in exclude_patterns:
                    include_dirs = [d for d in include_dirs if (not re.search(p, d))]
            if include_dirs:
                libs.append(db.get_lang_lib('PHP', 'inilib', include_dirs, 'PHP'))
        all_dirs = (list(extra_dirs) + list(include_dirs))
        num_import_dirs = len(all_dirs)
        if (num_import_dirs > 100):
            msg = ('This    buffer    is    configured    with    %d    %s    import    dirs:    this    may    result    in    poor    completion    performance' % (num_import_dirs, self.lang))
            self.mgr.report_message(msg, '\n'.join(all_dirs))
        catalog_selections = env.get_pref('codeintel_selected_catalogs')
        libs += [db.get_catalog_lib('PHP', catalog_selections), db.get_stdlib('PHP', php_ver)]
        env.cache[cache_key] = libs
    return env.cache[cache_key]
